/* /2048/ — 2048, the Pocket Games version (2048/2048.js). The game sits on
   the app's warm "table": cream panel, taupe tray, classic tile colours.
   Page frame, headline, rank box, SEO cards and FAQ come from games.css.
   Shared by all locales. */

.g2048-stage { inline-size: 100%; max-inline-size: 500px; margin: 0 auto; }
/* 2048.js builds the game inside the empty stage: hold its height (board +
   score row + footer) so the rank box below does not jump when it boots. */
.g2048-stage:empty { min-block-size: calc(min(100vw - 2 * var(--gutter, 16px) - 28px, 460px) + 168px); }
@media (max-width: 599px) { .g2048-stage:empty { min-block-size: calc(min(100vw - 2 * var(--gutter, 16px) - 28px, 460px) + 184px); } }
.g2048-lb-cta { display: flex; justify-content: center; }

.t2048-root, .play-layer:has(.t2048-root) {
  --t-bg: #faf8ef; --t-ink: #685d52; --t-muted: #77695c; --t-tray: #bbada0; --t-empty: #cdc1b4; --t-chip: #715c49; --t-border: #d0c2b0;
  --t-soft: #ece5d9;
}
.t2048-root {
  --t-board: min(100%, 460px);
  display: grid; justify-items: center; gap: 10px;
  padding: 14px 14px 12px; border-radius: 18px;
  background: var(--t-bg); color: var(--t-ink);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .28), inset 0 1px 0 #ffffffaa;
  -webkit-user-select: none; user-select: none;
}
.t2048-hud { display: flex; gap: 8px; inline-size: var(--t-board); }
.t2048-chip {
  flex: 1 1 0; display: grid; justify-items: center; align-content: center; gap: 1px; min-inline-size: 0;
  padding: 8px 10px; border: 0; border-radius: 10px; background: var(--t-chip); color: #fff;
  font: inherit; line-height: 1.1;
}
.t2048-chip--wide { flex-grow: 1.35; }
.t2048-chip > span { color: #fffaf2; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-inline-size: 100%; }
.t2048-chip > b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.t2048-chip > b i { font-style: normal; }
.t2048-undo { flex-grow: .85; cursor: pointer; transition: transform 120ms ease, opacity 120ms ease; }
.t2048-undo:hover:not(:disabled) { filter: brightness(1.08); }
.t2048-undo:active:not(:disabled) { transform: scale(.96); }
.t2048-undo:disabled { opacity: .45; cursor: default; }
.t2048-undo:focus-visible, .t2048-btn:focus-visible, .t2048-new:focus-visible { outline: 2px solid #9e8569; outline-offset: 3px; }

.t2048-wrap { position: relative; inline-size: var(--t-board); }
.t2048 {
  position: relative; container-type: inline-size;
  inline-size: 100%; aspect-ratio: 1; padding: 8px;
  border-radius: 14px; background: var(--t-tray);
  box-shadow: 0 9px 20px #3f251018, inset 0 1px 0 #ffffff3b;
  touch-action: none; outline: none;
}
.t2048:focus-visible { box-shadow: 0 0 0 3px #9e8569, 0 9px 20px #3f251018; }
.t2048-cells, .t2048-tiles { position: absolute; inset: 8px; }
.t2048-cells { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 8px; }
.t2048-cells i { border-radius: 9px; background: var(--t-empty); }
.t2048-tile {
  position: absolute; left: 0; top: 0;
  inline-size: calc((100% - 24px) / 4); block-size: calc((100% - 24px) / 4);
  display: grid; place-items: center; border-radius: 9px;
  font-weight: 900; font-size: clamp(14px, 8.5cqw, 40px); line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 160ms cubic-bezier(.23, 1, .32, 1);
  will-change: transform;
}
.t2048-tile.vmid { font-size: clamp(12px, 7.4cqw, 34px); }
.t2048-tile.vbig { font-size: clamp(10px, 6cqw, 28px); }
.t2048-tile.merged { z-index: 2; }
.t2048-tile.ghost { z-index: 3; }
.t2048-face { display: grid; place-items: center; inline-size: 100%; block-size: 100%; border-radius: inherit; box-shadow: 0 3px 4px #3f251012, inset 0 1px 0 #ffffff44; }
.t2048-tile.fresh .t2048-face { animation: t2048Pop 180ms cubic-bezier(.23, 1, .32, 1); }
.t2048-tile.merged .t2048-face { animation: t2048Merge 260ms cubic-bezier(.23, 1, .32, 1); }
.t2048-tile.ghost .t2048-face { animation: t2048Meet 160ms cubic-bezier(.23, 1, .32, 1) forwards; }
.t2048-tile[data-value="2048"] .t2048-face { box-shadow: 0 0 22px #edc22e99, inset 0 1px 0 #ffffff66; }
@keyframes t2048Pop { from { transform: scale(.94); opacity: .25; } to { transform: scale(1); opacity: 1; } }
@keyframes t2048Merge { 0%, 55% { transform: scale(.96); opacity: 0; } 65% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes t2048Meet { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* Juice: milestone praise, a nudge when a swipe does nothing, shake on a stuck board, confetti at 2048. */
.t2048-praise {
  position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 2px;
  pointer-events: none; opacity: 0; color: #fff; text-shadow: 0 2px 10px #5a3d1e88;
}
.t2048-praise b { font-size: clamp(30px, 14cqw, 64px); font-weight: 900; letter-spacing: -.03em; }
.t2048-praise small { font-size: clamp(14px, 5cqw, 22px); font-weight: 800; }
.t2048-praise.on { animation: t2048Praise 1300ms cubic-bezier(.23, 1, .32, 1) forwards; }
@keyframes t2048Praise { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.06); } 25% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.t2048.nudge[data-nudge="left"] { animation: t2048NudgeX 160ms ease reverse; }
.t2048.nudge[data-nudge="right"] { animation: t2048NudgeX 160ms ease; }
.t2048.nudge[data-nudge="up"] { animation: t2048NudgeY 160ms ease reverse; }
.t2048.nudge[data-nudge="down"] { animation: t2048NudgeY 160ms ease; }
@keyframes t2048NudgeX { 0%, 100% { transform: none; } 40% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes t2048NudgeY { 0%, 100% { transform: none; } 40% { transform: translateY(-4px); } 50% { transform: translateY(4px); } }
.t2048.shake { animation: t2048Shake 460ms cubic-bezier(.36, .07, .19, .97); }
@keyframes t2048Shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
.t2048-confetti {
  position: absolute; z-index: 7; inline-size: 9px; block-size: 13px; border-radius: 2px; pointer-events: none;
  animation: t2048Confetti 1100ms cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes t2048Confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), calc(var(--dy) + 160px)) rotate(var(--r)); opacity: 0; } }

.t2048-hint { margin: 0; padding: 2px 6px 0; max-inline-size: var(--t-board); text-align: center; font-size: 12px; font-weight: 650; line-height: 1.5; color: var(--t-muted); }
.t2048-keys { font-weight: 500; }
.t2048-bar { display: flex; justify-content: center; }
.t2048-new, .t2048-btn {
  appearance: none; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 800; transition: filter 120ms ease, transform 120ms ease;
}
.t2048-new { padding: 8px 16px; background: var(--t-soft); color: var(--t-ink); font-size: 13px; }
.t2048-new:hover, .t2048-btn:hover { filter: brightness(1.06); }
.t2048-new:active, .t2048-btn:active { transform: scale(.97); }

/* Standalone start / pause / result card (hidden while the play layer is open). */
.t2048-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 12px; border-radius: 14px; background: #faf8efd9; backdrop-filter: blur(2px); }
.t2048-overlay[hidden] { display: none; }
.t2048-card { display: grid; justify-items: center; gap: 8px; max-inline-size: 320px; text-align: center; animation: t2048Pop 220ms cubic-bezier(.23, 1, .32, 1); }
.t2048-kicker { margin: 0; min-block-size: 1em; color: var(--t-muted); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.t2048-title { margin: 0; color: var(--t-ink); font-family: inherit; font-size: clamp(30px, 9vw, 44px); font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.t2048-sub { margin: 0; color: var(--t-muted); font-size: 14px; line-height: 1.45; }
.t2048-sub:empty { display: none; }
.t2048-actions { display: grid; gap: 8px; inline-size: min(100%, 260px); margin-block-start: 6px; }
.t2048-btn { display: grid; gap: 2px; padding: 11px 16px; background: var(--t-soft); color: var(--t-ink); font-size: 15px; }
.t2048-btn small { font-size: 11px; font-weight: 600; opacity: .85; }
.t2048-btn--primary { background: var(--t-chip); color: #fff; box-shadow: 0 4px 0 #6f5d4c; }

/* Play layer: the table fills the slot; the board takes what height is left. */
html.play-open .g2048-stage { max-inline-size: none; inline-size: auto; }
html.play-open .t2048-root {
  --t-board: min(calc(100vw - 2 * var(--gutter, 16px) - 28px), calc(100dvh - 300px), 520px);
  margin-inline: auto; inline-size: fit-content;
}
html.play-open .t2048-overlay { display: none; }
html.play-open .t2048-bar { display: none; }
@media (max-width: 599px) {
  html.play-open .t2048-root { --t-board: min(calc(100vw - 2 * var(--gutter, 16px) - 20px), calc(100dvh - 260px), 520px); padding: 10px; }
}
@media (pointer: coarse) { .t2048-keys { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .t2048-tile { transition: none; }
  .t2048-tile.fresh .t2048-face, .t2048-tile.merged .t2048-face, .t2048-tile.ghost .t2048-face { animation: none; }
  .t2048-tile.ghost { visibility: hidden; }
  .t2048-praise.on { animation: t2048Fade 1300ms linear forwards; }
  .t2048.nudge, .t2048.shake, .t2048-card { animation: none !important; }
  .t2048-new, .t2048-btn, .t2048-undo { transition: none; }
}
@keyframes t2048Fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* /2048-leaderboard/: season label and the read-only Classic boards (2048/2048-classic-lb.js). */
.lb2048-season { display: flex; align-items: center; justify-content: center; gap: var(--space-2, 8px); margin: 0 auto var(--space-3, 12px); color: var(--amber, #ffb000); font-weight: 700; font-size: var(--step--1, .9rem); letter-spacing: .02em; }
.lb2048-classic { display: grid; gap: var(--space-3, 12px); }
.lb2048-classic[hidden] { display: none; }
.lb2048-classic-note { margin: 0; text-align: center; color: var(--text-muted); font-size: var(--step--1, .9rem); }
/* The warm game table becomes the full active play ground. Tile colours,
   square board geometry and the game's own score/undo HUD remain intact. */
html:not([data-embed]) .play-layer:has(.t2048-root) .play-backdrop { background: var(--t-bg); }
html:not([data-embed]) .play-layer:has(.t2048-root) .play-bar { background: var(--t-bg); border-color: var(--t-border); }
html:not([data-embed]) .play-layer:has(.t2048-root) :is(.play-bar__btn, .play-bar__logo) { color: var(--t-ink); }
html:not([data-embed]) .play-layer:has(.t2048-root) .play-bar__btn:hover { background: var(--t-soft); }
html:not([data-embed]) .play-layer:has(.t2048-root) .play-bar__score { visibility: hidden; }
html:not([data-embed]) .play-layer .t2048-root { background: transparent; border-radius: 0; box-shadow: none; }
@media (max-width: 599px) {
  html:not([data-embed]).play-open .t2048-root { --t-board: min(calc(100vw - 36px), calc(var(--play-slot-h, 584px) - 112px), 520px); }
}


