:root { --bg1: #7048e8; --bg2: #e64980; --accent: #0B4DA2; --accent-ink: #fff; --panel-ink: #062A5F; --muted: #3D5B8C; --gap: 10px; --board: 440px; }
.board {
  position: relative; width: var(--board); height: var(--board); padding: var(--gap);
  border-radius: 22px; background: rgba(40, 15, 90, .35);
  box-shadow: 0 14px 30px rgba(30,0,60,.3), inset 0 -6px 0 rgba(0,0,0,.15);
  touch-action: none;
}
.cells, .tiles { position: absolute; inset: var(--gap); }
.cells { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: var(--gap); }
.cell { border-radius: 14px; background: rgba(255,255,255,.18); }
.tile {
  --r: 0; --c: 0;
  position: absolute; top: 0; left: 0;
  width: calc((100% - 3 * var(--gap)) / 4); height: calc((100% - 3 * var(--gap)) / 4);
  transform: translate(calc(var(--c) * (100% + var(--gap))), calc(var(--r) * (100% + var(--gap))));
  transition: transform 110ms ease-in-out;
  z-index: 2;
}
.tile .face {
  width: 100%; height: 100%; border-radius: 14px; display: grid; place-items: center;
  font-weight: 900; font-size: calc(var(--board) / 8.2); color: #fff; line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 4px 10px rgba(0,0,0,.12);
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.tile.d3 .face { font-size: calc(var(--board) / 10); }
.tile.d4 .face { font-size: calc(var(--board) / 12.5); }
.tile.d5 .face { font-size: calc(var(--board) / 15); }
.tile.is-new .face { animation: appear .18s ease .1s backwards; }
.tile.is-merged { z-index: 3; }
.tile.is-merged .face { animation: pop .2s ease .1s backwards; }
.tile.is-leaving { z-index: 1; }

.v2 .face { background: #fff3bf; color: #8a5a00; text-shadow: none; }
.v4 .face { background: #ffe066; color: #7a4b00; text-shadow: none; }
.v8 .face { background: #ffa94d; }
.v16 .face { background: #ff8787; }
.v32 .face { background: #f783ac; }
.v64 .face { background: #e64980; }
.v128 .face { background: #da77f2; box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 0 16px rgba(218,119,242,.6); }
.v256 .face { background: #9775fa; box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 0 18px rgba(151,117,250,.6); }
.v512 .face { background: #5c7cfa; box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 0 20px rgba(92,124,250,.6); }
.v1024 .face { background: #22b8cf; box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 0 22px rgba(34,184,207,.7); }
.v2048 .face { background: linear-gradient(135deg, #20c997, #12b886); box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 0 28px rgba(32,201,151,.9); }
.vbig .face { background: linear-gradient(135deg, #343a40, #212529); box-shadow: inset 0 -6px 0 rgba(0,0,0,.3), 0 0 24px rgba(255,212,59,.7); color: #ffd43b; }

.toolbar { display: flex; gap: 12px; justify-content: center; flex: 0 0 auto; padding-bottom: 4px; }
.toolbar .btn { min-height: 52px; font-size: 18px; }
.pill { background: var(--panel-ink); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.board.shake { animation: shake .3s ease; }

@keyframes appear { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
