/* ==========================================================================
   PlayLite — per-game board styles (loaded on game pages only)
   Games added later inject their own scoped CSS via PLG.css(), so only the
   original board-based games need rules here.
   ========================================================================== */

/* ------------------------------------------------------------------- 2048 */
body[data-game="2048"] .game-head { padding-top: 22px; }
body[data-game="2048"] .game-head h1 { font-size: clamp(2rem, 6vw, 3rem); }
body[data-game="2048"] .game-head .tagline { max-width: 46ch; }
body[data-game="2048"] .game-shell { max-width: 760px; }
body[data-game="2048"] .game-frame {
  max-width: 520px;
  min-height: min(650px, calc(100vw + 100px));
  padding: 18px;
  border-radius: 20px;
}

.g2048-app {
  width: min(100%, 460px);
  margin: 0 auto;
}
.g2048-scorebar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.g2048-mark {
  display: grid;
  grid-template-columns: repeat(2, 23px);
  grid-template-rows: repeat(2, 23px);
  gap: 3px;
  padding: 6px;
  border-radius: 10px;
  background: #3f3a36;
  box-shadow: var(--sh-1);
}
.g2048-mark span {
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #eee4da;
  color: #4b463f;
  font-size: .7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.g2048-mark span:last-child { background: #f2b179; color: #fffaf4; }
.g2048-stats { display: grid; grid-template-columns: repeat(2, minmax(92px, 1fr)); gap: 8px; }
.g2048-stat {
  min-width: 92px;
  padding: 8px 14px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  text-align: right;
}
.g2048-stat span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
}
.g2048-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}

.g2048-board {
  --g2048-gap: 10px;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 12px;
  border-radius: 14px;
  background: #bbada0;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 22%), 0 10px 24px rgb(72 58 48 / 13%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
  outline: none;
}
.g2048-board:focus-visible {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 30%, transparent),
    inset 0 1px 0 rgb(255 255 255 / 22%), 0 10px 24px rgb(72 58 48 / 13%);
}
.g2048-grid {
  position: absolute;
  inset: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--g2048-gap);
}
.g2048-cell { border-radius: 8px; background: rgb(238 228 218 / 35%); }
.g2048-tiles { position: absolute; inset: 0; }
.g2048-tile {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgb(72 58 48 / 8%), inset 0 1px 0 rgb(255 255 255 / 16%);
  font-size: clamp(1.1rem, 7vw, 2.25rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  transform-origin: center;
}
.g2048-tile.tile-128,
.g2048-tile.tile-256,
.g2048-tile.tile-512 { font-size: clamp(1rem, 6vw, 1.9rem); }
.g2048-tile.tile-1024,
.g2048-tile.tile-2048,
.g2048-tile.tile-super { font-size: clamp(.82rem, 5vw, 1.55rem); }
.g2048-tile.is-moving {
  z-index: 4;
  transition: transform 140ms var(--ease-out);
  will-change: transform;
}
.g2048-tile.is-spawned { animation: g2048-spawn 140ms var(--ease-out); }
.g2048-tile.is-merged { animation: g2048-merge 160ms var(--ease-out); }
@keyframes g2048-spawn { from { opacity: .65; scale: .8; } to { opacity: 1; scale: 1; } }
@keyframes g2048-merge { 0% { scale: 1; } 52% { scale: 1.1; } 100% { scale: 1; } }

.g2048-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.g2048-toolbar .btn { min-height: 44px; }
.g2048-toolbar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.g2048-controls {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: .82rem;
}
.g2048-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.g2048-tutorial {
  margin-top: 15px;
  padding: 14px 15px;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--text-2);
}
.g2048-tutorial strong { display: block; color: var(--text); font-size: .92rem; }
.g2048-tutorial ol {
  display: grid;
  gap: 5px;
  margin: 9px 0 12px;
  padding-left: 20px;
  font-size: .84rem;
}
.g2048-tutorial li::marker { color: var(--brand); font-weight: 800; }
.g2048-dialog {
  width: min(92vw, 390px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--sh-4);
}
.g2048-dialog::backdrop { background: rgb(10 12 18 / 52%); }
.g2048-dialog form { padding: 24px; }
.g2048-dialog h2 { margin: 0 0 7px; font-size: 1.25rem; letter-spacing: -.02em; }
.g2048-dialog p { margin: 0; color: var(--muted); font-size: .92rem; }
.g2048-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

@media (max-width: 560px) {
  body[data-game="2048"] .game-head { padding-top: 15px; }
  body[data-game="2048"] .game-frame { margin-top: 16px; padding: 12px; border-radius: 16px; }
  .g2048-board { --g2048-gap: 8px; padding: 10px; border-radius: 12px; }
  .g2048-grid { inset: 10px; }
  .g2048-cell, .g2048-tile { border-radius: 7px; }
  .g2048-mark { grid-template-columns: repeat(2, 20px); grid-template-rows: repeat(2, 20px); }
  .g2048-stats { grid-template-columns: repeat(2, minmax(78px, 1fr)); }
  .g2048-stat { min-width: 78px; padding-inline: 10px; }
  .g2048-dialog-actions { flex-direction: column-reverse; }
  .g2048-dialog-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .g2048-tile.is-moving { transition-duration: .01ms; }
  .g2048-tile.is-spawned,
  .g2048-tile.is-merged { animation: none; }
}

/* ------------------------------------------------------------ minesweeper */
.mine-board { gap: 3px; max-width: 100%; overflow: auto; padding-bottom: 4px; }
.mine-cell {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--card-3); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 800; font-size: .9rem;
  cursor: pointer; user-select: none;
  transition: background .1s var(--ease);
}
.mine-cell:not(.open):hover { background: var(--brand-soft); }
.mine-cell.open { background: var(--bg-soft); border-color: transparent; cursor: default; }
.mine-cell.boom { background: var(--bad); color: #fff; }
@media (max-width: 480px) { .mine-cell { width: 30px; height: 30px; } }

/* ----------------------------------------------------------- memory match */
.mem-board { grid-template-columns: repeat(4, minmax(58px, 84px)); }
.mem-card { aspect-ratio: 1; border-radius: 12px; cursor: pointer; perspective: 600px; position: relative; }
.mem-inner { position: absolute; inset: 0; transition: transform .32s var(--ease-out); transform-style: preserve-3d; }
.mem-card.flip .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; border-radius: 12px;
  display: grid; place-items: center; font-size: clamp(22px, 6vw, 34px);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.mem-back {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 20px;
}
.mem-front {
  background: var(--card-2); border: 1px solid var(--line); transform: rotateY(180deg);
}
.mem-card.done .mem-front { background: color-mix(in srgb, var(--good) 18%, var(--card-2)); }

/* ----------------------------------------------------------------- sudoku */
.sudoku-board {
  grid-template-columns: repeat(9, minmax(30px, 46px));
  gap: 0; border: 2px solid var(--text); border-radius: 6px; overflow: hidden;
}
.su-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  font-weight: 700; font-size: clamp(.9rem, 3.4vw, 1.15rem);
  background: var(--card); border: 1px solid var(--line);
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.su-cell.given { background: var(--bg-soft); cursor: default; }
.su-cell.sel { background: var(--brand-soft); outline: 2px solid var(--brand); outline-offset: -2px; }
.su-cell.same { background: color-mix(in srgb, var(--brand-soft) 60%, var(--card)); }
.su-cell.bad { color: var(--bad); }
.su-cell.br { border-right: 2px solid var(--text); }
.su-cell.bb { border-bottom: 2px solid var(--text); }
.su-pad { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 420px; }
.su-pad button {
  width: 42px; height: 46px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card-2); font-size: 1.1rem; font-weight: 700; cursor: pointer;
  color: var(--text); font-family: inherit;
}
.su-pad button:active { background: var(--brand); color: var(--brand-ink); }

/* ------------------------------------------------------------- word guess */
.wg-board { grid-template-rows: repeat(6, 1fr); gap: 6px; }
.wg-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wg-tile {
  width: min(15vw, 60px); height: min(15vw, 60px);
  border: 2px solid var(--line-2); border-radius: 8px;
  display: grid; place-items: center;
  font-size: clamp(1.1rem, 6vw, 1.7rem); font-weight: 800; text-transform: uppercase;
  transition: transform .1s var(--ease), background .25s var(--ease), border-color .25s var(--ease);
}
.wg-tile.filled { border-color: var(--muted); transform: scale(1.04); }
.wg-tile.correct { background: var(--good); border-color: var(--good); color: #fff; }
.wg-tile.present { background: var(--accent); border-color: var(--accent); color: #fff; }
.wg-tile.absent { background: var(--muted); border-color: var(--muted); color: var(--card); }

/* --------------------------------------------------------- sliding puzzle */
.slide-board { background: var(--bg-soft); padding: 8px; border-radius: 14px; gap: 6px; touch-action: none; }
.slide-tile {
  border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: clamp(1rem, 5vw, 1.5rem); cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: transform .1s var(--ease);
}
.slide-tile:active { transform: scale(.95); }
.slide-hole { background: transparent; }

/* ------------------------------------------------------------ tic-tac-toe */
.ttt-board { grid-template-columns: repeat(3, minmax(78px, 108px)); gap: 8px; }
.ttt-cell {
  aspect-ratio: 1; border-radius: 15px; background: var(--card-2);
  border: 1px solid var(--line); font-size: clamp(2rem, 9vw, 3rem); font-weight: 800;
  display: grid; place-items: center; cursor: pointer; color: var(--text);
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.ttt-cell:hover { border-color: var(--brand); }
.ttt-cell.win { background: color-mix(in srgb, var(--good) 22%, var(--card-2)); border-color: var(--good); }
.ttt-x { color: var(--brand); }
.ttt-o { color: var(--accent); }

/* ---------------------------------------------------------- whack-a-mole */
.mole-board { grid-template-columns: repeat(3, minmax(80px, 110px)); gap: 12px; }
.mole-hole {
  aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--bg-soft), var(--line));
  display: grid; place-items: center; font-size: clamp(2.2rem, 10vw, 3.4rem);
  cursor: pointer; overflow: hidden; user-select: none;
  border: 1px solid var(--line);
}
.mole-hole .mole { transform: translateY(120%); transition: transform .12s var(--ease-out); pointer-events: none; }
.mole-hole.up .mole { transform: translateY(0); }
.mole-hole.bonk .mole { transform: translateY(10%) scale(.85) rotate(12deg); }

/* -------------------------------------------------------------- reaction */
.react-zone {
  width: 100%; max-width: 520px; height: 300px; border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; font-weight: 800; font-size: 1.25rem; text-align: center;
  background: var(--card-2); color: var(--text); user-select: none; padding: 18px;
  border: 1px solid var(--line);
  transition: background .1s var(--ease);
}
.react-zone.wait { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.react-zone.go { background: var(--good); color: #fff; border-color: var(--good); }
.react-zone .small { font-size: .86rem; font-weight: 600; opacity: .85; }

/* ---------------------------------------------------------- block puzzle */
.bp-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.bp-board {
  --bp-cell: min(8vw, 36px);
  display: grid; grid-template-columns: repeat(10, var(--bp-cell));
  grid-auto-rows: var(--bp-cell); gap: 3px;
  background: var(--bg-soft); padding: 6px; border-radius: 12px; touch-action: none;
}
.bp-cell { border-radius: 5px; background: var(--line); }
.bp-cell.filled { background: var(--brand); }
.bp-cell.preview { background: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.bp-cell.clearing { animation: bpclear .26s var(--ease) forwards; }
@keyframes bpclear { to { transform: scale(.2); opacity: 0; } }
.bp-tray { display: flex; gap: 18px; justify-content: center; min-height: 90px; align-items: center; }
.bp-piece { display: grid; gap: 3px; cursor: grab; touch-action: none; }
.bp-piece.used { visibility: hidden; }
.bp-piece .pc { width: 22px; height: 22px; border-radius: 4px; background: var(--brand-2); }
.bp-piece .pc.empty { background: transparent; }
.bp-ghost { position: fixed; z-index: 99; pointer-events: none; display: grid; gap: 3px; opacity: .85; }
.bp-ghost .pc { width: var(--bp-cell, 34px); height: var(--bp-cell, 34px); border-radius: 5px; background: var(--brand-2); }
.bp-ghost .pc.empty { background: transparent; }
