/* sixtyfour.css - 64: a short 2048-style merge game.
   4x4 grid, swipe (8 directions, diagonals included) or arrow keys /
   WASD / QEZC to slide; equal tiles merge up the chain; two tiles of
   the current max tier pop and disappear, filling a bucket -- fill the
   bucket to climb a level, a bigger tile unlocks every 5 levels. A full
   board with no moves left loses; the next run starts 3 levels below
   your best. Reuses tokens from styles.css and game-shell.css's
   shell/bar/pause chrome, same as every other game. No joystick --
   entirely swipe/keyboard-driven, closer to Sliders' control-free
   posture than the twin-stick games. */

.sixtyfour-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  gap: 8px;
}

.sixtyfour-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .sixtyfour-stats {
    padding: 0 var(--gs-bar-right-clear) 0 var(--gs-bar-left-clear);
    gap: 12px;
  }
}

.sixtyfour-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  min-width: 56px;
}

.sixtyfour-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--muted);
}

.sixtyfour-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Turn countdown (Jeff, Nov 8, 2026): the Turns value turns red when
   the run is nearly out of turns (10 or fewer), so the player sees the
   countdown ending without anything flashing or demanding focus. */
.sixtyfour-stat-value.is-low {
  color: #f87171;
}

.sixtyfour-board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sixtyfour-board {
  position: relative;
  width: min(100%, 400px);
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Swipes drive the game -- never let the browser turn one into a
     scroll or a pull-to-refresh. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sixtyfour-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
}

.sixtyfour-cell {
  background: rgba(255, 255, 255, .04);
  border-radius: 8px;
}

.sixtyfour-tiles {
  position: absolute;
  inset: 0;
}

.sixtyfour-tile {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 800;
  font-size: 30px;
  color: #f9f6f2;
  font-variant-numeric: tabular-nums;
  /* Slide animation -- the JS moves tiles by changing transform; the
     transition is what makes the slide visible rather than a jump. */
  transition: transform 120ms ease-out;
  /* Subtle bevel, same treatment as Sliders' tiles per explicit
     instruction there ("whitening of the left and upper edges just a
     few pixels and darkening of bottom and right edges"): light on the
     top/left, dark on the bottom/right, just a couple of pixels, so
     each tile reads as slightly raised. */
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .28),
    inset 2px 0 0 rgba(255, 255, 255, .20),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16);
}

/* A tile absorbed by a merge slides into the merge cell and fades out
   there -- needs its own opacity transition, since the base rule only
   transitions transform. */
.sixtyfour-tile.is-absorbed {
  opacity: 0;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

/* New tiles pop in -- `scale` is a separate property from `transform`
   in Chromium, so this never fights the slide positioning above. */
.sixtyfour-tile.is-new {
  animation: sixtyfour-pop 160ms ease-out;
}

@keyframes sixtyfour-pop {
  0% { scale: 0.4; opacity: 0; }
  100% { scale: 1; opacity: 1; }
}

/* A tile that just merged pulses briefly so the merge reads. */
.sixtyfour-tile.is-merged {
  animation: sixtyfour-merge-pulse 180ms ease-out;
}

@keyframes sixtyfour-merge-pulse {
  0% { scale: 1; }
  45% { scale: 1.12; }
  100% { scale: 1; }
}

/* Two max-tier tiles merging pop and disappear: they scale up, flash,
   and shrink away at the merge cell. The JS removes the element after
   260ms, on the tile's own timer (the pop outlives the slide cleanup). */
.sixtyfour-tile.is-popping {
  animation: sixtyfour-pop-out 260ms ease-in forwards;
  z-index: 3;
}

@keyframes sixtyfour-pop-out {
  0% { scale: 1; opacity: 1; }
  35% { scale: 1.3; opacity: 1; }
  100% { scale: 0.2; opacity: 0; }
}

/* The coloured ball (double-down tile): a bright magenta-to-violet
   gradient with a hot pink glow and a sparkle, so it stands out at any
   value. The [data-value] in the selector lifts specificity above the
   value-colour rules below, so a coloured tile is magenta at every
   value -- a coloured 64 is magenta, not gold. */
.sixtyfour-tile[data-value].is-coloured {
  background: linear-gradient(135deg, #ff2ea6 0%, #c026d3 55%, #7c3aed 100%);
  color: #fff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .45),
    inset 2px 0 0 rgba(255, 255, 255, .3),
    inset 0 -2px 0 rgba(0, 0, 0, .25),
    inset -2px 0 0 rgba(0, 0, 0, .18),
    0 0 20px rgba(255, 46, 166, .8),
    0 0 6px rgba(255, 46, 166, .9);
  animation: sixtyfour-sparkle 1.1s ease-in-out infinite;
}

.sixtyfour-tile[data-value].is-coloured::after {
  content: '✦';
  position: absolute;
  top: 1px;
  right: 5px;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  opacity: .95;
  text-shadow: 0 0 6px rgba(255, 255, 255, .9);
}

@keyframes sixtyfour-sparkle {
  0%, 100% { box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .45),
    inset 2px 0 0 rgba(255, 255, 255, .3),
    inset 0 -2px 0 rgba(0, 0, 0, .25),
    inset -2px 0 0 rgba(0, 0, 0, .18),
    0 0 14px rgba(255, 46, 166, .55),
    0 0 4px rgba(255, 46, 166, .7); }
  50% { box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .45),
    inset 2px 0 0 rgba(255, 255, 255, .3),
    inset 0 -2px 0 rgba(0, 0, 0, .25),
    inset -2px 0 0 rgba(0, 0, 0, .18),
    0 0 26px rgba(255, 46, 166, .95),
    0 0 10px rgba(255, 46, 166, 1); }
}

/* Tile values -- classic 2048 ramp, with the 64 in the site's own gold
   (#f2b134) so the target tile is unmistakable. Higher tiles unlock
   every 5 levels (128 at 5, 256 at 10, 512 at 15, 1024 at 20, 2048 at
   25); each keeps the ramp going hotter/brighter so the current max
   tier always stands out. The base rule's muted purple is the catch-all
   for anything above 2048. */
.sixtyfour-tile { background: #8b7bb8; }
.sixtyfour-tile[data-value="2"] { background: #eee4da; color: #776e65; }
.sixtyfour-tile[data-value="4"] { background: #ede0c8; color: #776e65; }
.sixtyfour-tile[data-value="8"] { background: #f2b179; }
.sixtyfour-tile[data-value="16"] { background: #f59563; }
.sixtyfour-tile[data-value="32"] { background: #f67c5f; }
.sixtyfour-tile[data-value="64"] {
  background: #f2b134;
  color: #3a2a00;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .35),
    inset 2px 0 0 rgba(255, 255, 255, .25),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(242, 177, 52, .55);
}
.sixtyfour-tile[data-value="128"] {
  background: #f59e0b;
  color: #3a2a00;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .35),
    inset 2px 0 0 rgba(255, 255, 255, .25),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(245, 158, 11, .6);
}
.sixtyfour-tile[data-value="256"] {
  background: #f97316;
  color: #fff7ed;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .3),
    inset 2px 0 0 rgba(255, 255, 255, .22),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(249, 115, 22, .6);
}
.sixtyfour-tile[data-value="512"] {
  background: #a855f7;
  color: #faf5ff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .3),
    inset 2px 0 0 rgba(255, 255, 255, .22),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(168, 85, 247, .6);
}
.sixtyfour-tile[data-value="1024"] {
  background: #d946ef;
  color: #fdf4ff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .3),
    inset 2px 0 0 rgba(255, 255, 255, .22),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(217, 70, 239, .6);
}
.sixtyfour-tile[data-value="2048"] {
  background: #7c3aed;
  color: #f5f3ff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .3),
    inset 2px 0 0 rgba(255, 255, 255, .22),
    inset 0 -2px 0 rgba(0, 0, 0, .22),
    inset -2px 0 0 rgba(0, 0, 0, .16),
    0 0 18px rgba(124, 58, 237, .6);
}

.sixtyfour-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(242, 177, 52, .92);
  color: #3a2a00;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 5;
  white-space: nowrap;
}

.sixtyfour-toast[hidden] { display: none; }

.sixtyfour-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

/* -- Level-start flourish (Jeff, Nov 8, 2026) -------------------------------
   A gold "Level N" banner over the board centre, a burst of gold
   particles from the board centre, and a gold pulse on the board and
   its tiles. ~3.9s (3x the original ~1.3s, Jeff Nov 8, 2026),
   pointer-events: none throughout -- it never blocks play, so the
   next move can start immediately. */
.sixtyfour-level-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity .25s ease, transform .25s ease;
}

.sixtyfour-level-banner[hidden] { display: none; }

.sixtyfour-level-banner.is-visible {
  opacity: 1;
  transform: scale(1);
}

.sixtyfour-level-banner-title {
  font-family: Georgia, serif;
  font-size: 44px;
  font-weight: 700;
  color: #f2b134;
  text-shadow:
    0 0 24px rgba(242, 177, 52, .9),
    0 2px 0 rgba(0, 0, 0, .4);
}

.sixtyfour-level-banner-sub {
  font-size: 16px;
  font-weight: 700;
  color: #ffe9b0;
  text-shadow: 0 0 12px rgba(242, 177, 52, .8);
  margin-top: 4px;
}

.sixtyfour-burst-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #f2b134;
  box-shadow: 0 0 8px rgba(242, 177, 52, .9);
  pointer-events: none;
  z-index: 7;
  animation: sixtyfour-burst-fly 2700ms ease-out forwards;
}

@keyframes sixtyfour-burst-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

/* Board + tiles pulse gold while the banner is up. The tile pulse uses
   `scale` (a separate property from `transform` in Chromium), so it
   never fights the slide positioning. */
.sixtyfour-board.is-level-up {
  animation: sixtyfour-board-glow 2700ms ease-out;
}

@keyframes sixtyfour-board-glow {
  0%, 100% { box-shadow: var(--shadow); }
  30% { box-shadow: 0 0 0 2px rgba(242, 177, 52, .8), 0 0 32px rgba(242, 177, 52, .55); }
}

.sixtyfour-board.is-level-up .sixtyfour-tile {
  animation: sixtyfour-level-pulse 2700ms ease-out;
}

@keyframes sixtyfour-level-pulse {
  0% { scale: 1; }
  30% { scale: 1.08; }
  100% { scale: 1; }
}

.sixtyfour-hint {
  flex: 0 0 auto;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  padding: 0 12px;
}

/* -- Overlays (start/game-over) -- same pattern as every other game.
   The start overlay is lightened (.55) so the attract board behind it
   shows through, same posture as Slither/Spiders/Cubes/Vines; the
   game-over overlay keeps the darker .72. */

.sixtyfour-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 13, 16, .72);
  border-radius: var(--radius);
  z-index: 10;
}

.sixtyfour-overlay--start {
  background: rgba(10, 13, 16, .55);
}

.sixtyfour-overlay[hidden] { display: none; }

.sixtyfour-overlay-card {
  text-align: center;
  padding: 24px;
  max-width: 340px;
}

.sixtyfour-overlay-title {
  font-family: Georgia, serif;
  font-size: 26px;
  color: var(--text);
  margin-bottom: 8px;
}

.sixtyfour-overlay-text {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}

