/* Daily 2048 — warm paper board, tiles that climb from cream through gold, orange, red,
   plum, blue and green to a glowing gold 2048. Numbers are big Nunito 900. */
.t48-page {
  --t-gap: clamp(7px, 2.4vw, 12px);
  --t-board: #e7d6c1; --t-cell: #f3e7d7;
  --t-dur: 110ms;
}

.t48-card { padding: 16px; overflow-x: clip; }

/* ---- top bar ---- */
.t48-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.t48-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.t48-sub { font-weight: 800; font-size: 12.5px; color: var(--cbx-muted); padding-left: 4px; font-variant-numeric: tabular-nums; }
.t48-stats { display: flex; gap: 8px; flex: none; }
.t48-stat { position: relative; min-width: 76px; padding: 6px 12px 7px; border-radius: 14px; background: var(--cbx-ink); color: #fff; text-align: center; }
.t48-stat span { display: block; font-weight: 900; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #e9d8c6; }
.t48-stat b { display: block; font: 900 22px/1.1 var(--cbx-body); font-variant-numeric: tabular-nums; }
#bestBox { background: color-mix(in srgb, var(--cbx-accent) 88%, #000); }
#bestBox span { color: #ffe0d6; }
.t48-stat.bump b { animation: t48-bump .28s ease; }
.t48-float { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); pointer-events: none; font: 900 18px var(--cbx-body); color: var(--cbx-accent); text-shadow: 0 1px 0 #fff; animation: t48-float .8s ease-out forwards; white-space: nowrap; z-index: 3; }

.t48-banner { margin: 0 0 12px; padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--cbx-accent) 10%, #fff); border: 2px solid color-mix(in srgb, var(--cbx-accent) 30%, #fff); font-weight: 800; font-size: 14px; line-height: 1.4; text-align: center; color: var(--cbx-ink-2); }

/* ---- the board ---- */
.t48-board {
  position: relative; width: 100%; max-width: 460px; margin: 0 auto; aspect-ratio: 1;
  padding: var(--t-gap); border-radius: 20px; background: var(--t-board);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 4px 0 #d6c1a8, 0 14px 28px rgba(42,29,23,.12);
  touch-action: none; user-select: none; -webkit-user-select: none; container-type: inline-size; outline: none;
}
.t48-board:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--cbx-accent) 45%, transparent), 0 4px 0 #d6c1a8, 0 14px 28px rgba(42,29,23,.12); }
.t48-cells, .t48-tiles { position: absolute; inset: var(--t-gap); display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: var(--t-gap); }
.t48-cell { border-radius: 12px; background: var(--t-cell); box-shadow: inset 0 2px 4px rgba(120,90,60,.12); }
.t48-tiles { display: block; }

.t48-tile {
  --x: 0; --y: 0;
  position: absolute; left: 0; top: 0; width: calc((100% - 3 * var(--t-gap)) / 4); aspect-ratio: 1;
  transform: translate(calc(var(--x) * (100% + var(--t-gap))), calc(var(--y) * (100% + var(--t-gap))));
  transition: transform var(--t-dur) ease-in-out;
  z-index: 2; will-change: transform;
}
.t48-tile.under { z-index: 1; }
.t48-face {
  width: 100%; height: 100%; border-radius: 12px; display: grid; place-items: center;
  font: 900 13cqw/1 var(--cbx-body); letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: var(--bg, #fffaf3); color: var(--fg, var(--cbx-ink));
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.1), 0 2px 0 rgba(120,80,40,.12);
}
.t48-face.d3 { font-size: 10.5cqw; }
.t48-face.d4 { font-size: 8cqw; }
.t48-face.d5 { font-size: 6.4cqw; }
.t48-face.d6 { font-size: 5.2cqw; }
.t48-tile.new .t48-face { animation: t48-appear .18s ease-out both; }
.t48-tile.pop .t48-face { animation: t48-pop .2s cubic-bezier(.2,1.5,.4,1); }

/* tile colours */
.t48-tile[data-v="2"]    { --bg: #fffaf3; }
.t48-tile[data-v="4"]    { --bg: #f8e9d4; }
.t48-tile[data-v="8"]    { --bg: #fde2a4; }
.t48-tile[data-v="16"]   { --bg: #f9cb67; }
.t48-tile[data-v="32"]   { --bg: #f2b21b; }
.t48-tile[data-v="64"]   { --bg: #f37a32; --fg: #fff; }
.t48-tile[data-v="128"]  { --bg: #e2434b; --fg: #fff; }
.t48-tile[data-v="256"]  { --bg: #a24fcf; --fg: #fff; }
.t48-tile[data-v="512"]  { --bg: #4069e0; --fg: #fff; }
.t48-tile[data-v="1024"] { --bg: #16946a; --fg: #fff; }
.t48-tile[data-v="2048"] { --bg: linear-gradient(160deg, #ffe27a, #ffb020); --fg: #3a2300; }
.t48-tile[data-v="2048"] .t48-face { box-shadow: inset 0 -4px 0 rgba(150,80,0,.25), 0 0 0 3px rgba(255,200,60,.45), 0 0 22px rgba(255,176,32,.7); }
.t48-tile.big .t48-face { background: #2a1d17; color: #ffd24a; }
.t48-face { background: var(--bg, #fffaf3); }

/* bursts */
.t48-spark { position: absolute; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--cbx-accent)); pointer-events: none; z-index: 4; animation: t48-spark .6s ease-out forwards; }

/* game over veil */
.t48-over { position: absolute; inset: 0; z-index: 5; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; background: rgba(251,244,234,.3); text-align: center; animation: t48-fade .4s ease both; }
.t48-over b { font: 900 clamp(24px, 7.5cqw, 36px)/1.1 var(--cbx-display); color: var(--cbx-ink); background: rgba(255,255,255,.94); padding: 10px 18px 8px; border-radius: 16px 16px 6px 6px; box-shadow: 0 10px 24px rgba(42,29,23,.18); }
.t48-over span { font-weight: 900; font-size: 15px; color: #fff; background: var(--cbx-ink); padding: 6px 14px; border-radius: 6px 6px 14px 14px; margin-top: -2px; }
.t48-board.done .t48-over { pointer-events: none; }

/* ---- under the board ---- */
.t48-under { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; min-height: 44px; }
.t48-hint { margin: 0; font-weight: 800; font-size: 13.5px; color: var(--cbx-muted); line-height: 1.35; }
.t48-hint-keys { display: none; }
@media (hover: hover) and (pointer: fine) { .t48-hint-keys { display: inline; } .t48-hint-touch { display: none; } }
.t48-done { min-height: 44px; padding: 8px 16px; font-size: 15px; flex: none; }
.t48-done.confirm { background: var(--cbx-ink); color: #fff; box-shadow: 0 3px 0 #000; }
.t48-practice { display: flex; gap: 10px; margin-top: 12px; }
.t48-practice > * { flex: 1; min-height: 48px; font-size: 15px; padding: 10px 12px; }

/* ---- results ---- */
.t48-result { margin-top: 16px; padding-top: 14px; border-top: 2px dashed var(--cbx-line); }
.t48-vs { margin: 0 0 12px; padding: 10px 12px; border-radius: 14px; font-weight: 900; font-size: 15.5px; line-height: 1.35; background: var(--cbx-soft); color: var(--cbx-ink); }
.t48-vs.win { background: var(--cbx-good-soft); color: #136b3b; }
.t48-vs.lose { background: #fff1cc; color: #7a4b00; }
.t48-summary { font-size: 26px; letter-spacing: .12em; margin: 0 0 12px; }
.t48-res-actions { margin-top: 4px; }
.t48-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes t48-appear { from { transform: scale(0); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } to { transform: scale(1); } }
@keyframes t48-pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes t48-bump { 40% { transform: scale(1.15); } }
@keyframes t48-float { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -34px); } }
@keyframes t48-spark { from { transform: translate(0, 0) scale(1) rotate(0); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.3) rotate(160deg); opacity: 0; } }
@keyframes t48-fade { from { opacity: 0; } }

@media (max-width: 380px) {
  .t48-card { padding: 12px; }
  .t48-stat { min-width: 66px; padding: 5px 9px 6px; }
  .t48-stat b { font-size: 19px; }
  .t48-hint { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .t48-page { --t-dur: 0ms; }
  .t48-spark, .t48-float { display: none; }
}
