* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  color: #e6edf3;
  font-family: system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.wrap {
  width: min(100vw, 360px);
  padding: 12px;
  text-align: center;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.hud__title {
  font-weight: 700;
  letter-spacing: 0.06em;
}

.hud__score strong {
  color: #d29922;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid #30363d;
  background: #161b22;
  aspect-ratio: 1;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #21262d;
  font-size: clamp(18px, 6vw, 28px);
  font-weight: 700;
  color: #0d1117;
  transition: transform 0.08s ease;
}

.cell--empty {
  background: #21262d;
}

.cell--2 { background: #8b949e; color: #0d1117; }
.cell--4 { background: #6e7681; color: #0d1117; }
.cell--8 { background: #d29922; }
.cell--16 { background: #e3b341; }
.cell--32 { background: #f0883e; }
.cell--64 { background: #f85149; }
.cell--128 { background: #a371f7; font-size: clamp(16px, 5vw, 24px); }
.cell--256 { background: #8957e5; font-size: clamp(16px, 5vw, 24px); }
.cell--512 { background: #58a6ff; font-size: clamp(16px, 5vw, 24px); }
.cell--1024 { background: #3fb950; font-size: clamp(14px, 4.5vw, 20px); }
.cell--2048 { background: #238636; font-size: clamp(14px, 4.5vw, 20px); color: #fff; }

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: #8b949e;
  min-height: 1.2em;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}

.dpad__btn {
  border: 1px solid #30363d;
  border-radius: 10px;
  background: #21262d;
  color: #e6edf3;
  font-size: 18px;
  cursor: pointer;
}

.dpad__btn:active {
  background: #30363d;
}

.dpad__up { grid-column: 2; grid-row: 1; }
.dpad__left { grid-column: 1; grid-row: 2; }
.dpad__right { grid-column: 3; grid-row: 2; }
.dpad__down { grid-column: 2; grid-row: 3; }
