:root {
  --bg: #f7f1e3;
  --panel: #faf7ef;
  --grid: #bbada0;
  --cell: #cdc1b4;
  --text: #5f574f;
  --muted: #8f8175;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #f3efe6, #ece4d4);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
}

.game-wrap {
  width: min(560px, 100vw);
  margin: 0 auto;
  padding: 14px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.top h1 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1;
}

.top p {
  margin: 4px 0 0;
  color: var(--muted);
}

#newGameBtn {
  border: 0;
  border-radius: 10px;
  background: #8f7a66;
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

#newGameBtn:hover {
  filter: brightness(1.08);
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat {
  border-radius: 10px;
  background: #bbada0;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat span {
  color: #eee4da;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--grid);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  touch-action: none;
}

.cell {
  border-radius: 8px;
  background: var(--cell);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 800;
  font-size: 1.7rem;
  color: #776e65;
  user-select: none;
}

.tile-2 { background: #eee4da; }
.tile-4 { background: #ede0c8; }
.tile-8 { background: #f2b179; color: #fff; }
.tile-16 { background: #f59563; color: #fff; }
.tile-32 { background: #f67c5f; color: #fff; }
.tile-64 { background: #f65e3b; color: #fff; }
.tile-128 { background: #edcf72; color: #fff; font-size: 1.45rem; }
.tile-256 { background: #edcc61; color: #fff; font-size: 1.45rem; }
.tile-512 { background: #edc850; color: #fff; font-size: 1.45rem; }
.tile-1024 { background: #edc53f; color: #fff; font-size: 1.15rem; }
.tile-2048 { background: #edc22e; color: #fff; font-size: 1.15rem; }
.tile-super { background: #3c3a32; color: #fff; font-size: 1.05rem; }

.tip {
  color: var(--muted);
  text-align: center;
  margin: 12px 0 0;
}

.overlay {
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  background: rgba(238, 228, 218, 0.82);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 12px;
}

.overlay h2 {
  margin: 0;
  font-size: 2rem;
}

.overlay button {
  border: 0;
  border-radius: 8px;
  background: #8f7a66;
  color: #fff;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}
