:root {
  --bg: #faf8ef;
  --ink: #3c3a32;
  --muted: #776e65;
  --board: #bbada0;
  --cell: #cdc1b4;
  --accent: #8f7a66;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}
.wrap { width: 100%; max-width: 440px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
h1 { font-size: 46px; line-height: 1; color: var(--muted); letter-spacing: -1px; }
.sub { font-size: 14px; color: var(--muted); margin-top: 6px; }
.scores { display: flex; gap: 8px; }
.box {
  background: var(--board);
  color: #fff;
  border-radius: 6px;
  padding: 8px 14px;
  text-align: center;
  min-width: 74px;
}
.box span { display: block; font-size: 11px; letter-spacing: .06em; color: #eee4da; }
.box strong { font-size: 20px; }
.bar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }
button {
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #d8cfc4;
  color: var(--ink);
}
button.primary { background: var(--accent); color: #f9f6f2; }
button:disabled { opacity: .45; cursor: not-allowed; }
.board-wrap { position: relative; }
.grid {
  background: var(--board);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  touch-action: none;
}
.tile {
  background: var(--cell);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 32px;
  user-select: none;
  transition: transform 90ms ease;
}
.t-2 { background: #eee4da; color: #776e65; }
.t-4 { background: #ede0c8; color: #776e65; }
.t-8 { background: #f2b179; color: #f9f6f2; }
.t-16 { background: #f59563; color: #f9f6f2; }
.t-32 { background: #f67c5f; color: #f9f6f2; }
.t-64 { background: #f65e3b; color: #f9f6f2; }
.t-128 { background: #edcf72; color: #f9f6f2; font-size: 26px; }
.t-256 { background: #edcc61; color: #f9f6f2; font-size: 26px; }
.t-512 { background: #edc850; color: #f9f6f2; font-size: 26px; }
.t-1024 { background: #edc53f; color: #f9f6f2; font-size: 21px; }
.t-2048 { background: #edc22e; color: #f9f6f2; font-size: 21px; }
.t-big { background: #3c3a32; color: #f9f6f2; font-size: 19px; }
.overlay {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(238, 228, 218, .78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.overlay p { font-size: 30px; font-weight: 700; color: var(--muted); }
.hidden { display: none; }
.help { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
