:root {
  --background: #faf8ef;
  --board: #bbada0;
  --cell: rgba(238, 228, 218, 0.35);
  --text-dark: #776e65;
  --text-light: #f9f6f2;
  --accent: #8f7a66;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text-dark);
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
}

.container {
  width: min(92vw, 480px);
  margin: 24px auto;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 64px;
  margin: 0;
}

.scores {
  display: flex;
  gap: 8px;
}

.score-box {
  background: var(--board);
  border-radius: 6px;
  padding: 6px 16px;
  text-align: center;
  color: var(--text-light);
  min-width: 80px;
}

.score-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  color: #eee4da;
}

.score-value {
  font-size: 22px;
  font-weight: bold;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
}

.toolbar p {
  margin: 0;
}

button {
  background: var(--accent);
  color: var(--text-light);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

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

.cell {
  background: var(--cell);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: clamp(20px, 7vw, 44px);
  animation: pop 120ms ease-in-out;
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  100% {
    transform: scale(1);
  }
}

.tile-2 { background: #eee4da; color: var(--text-dark); }
.tile-4 { background: #ede0c8; color: var(--text-dark); }
.tile-8 { background: #f2b179; color: var(--text-light); }
.tile-16 { background: #f59563; color: var(--text-light); }
.tile-32 { background: #f67c5f; color: var(--text-light); }
.tile-64 { background: #f65e3b; color: var(--text-light); }
.tile-128 { background: #edcf72; color: var(--text-light); font-size: clamp(18px, 6vw, 38px); }
.tile-256 { background: #edcc61; color: var(--text-light); font-size: clamp(18px, 6vw, 38px); }
.tile-512 { background: #edc850; color: var(--text-light); font-size: clamp(18px, 6vw, 38px); }
.tile-1024 { background: #edc53f; color: var(--text-light); font-size: clamp(14px, 5vw, 30px); }
.tile-2048 { background: #edc22e; color: var(--text-light); font-size: clamp(14px, 5vw, 30px); }
.tile-super { background: #3c3a32; color: var(--text-light); font-size: clamp(14px, 5vw, 30px); }

.overlay {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(238, 228, 218, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1;
}

.overlay.hidden,
.hidden {
  display: none;
}

.overlay-text {
  font-size: 44px;
  font-weight: bold;
  margin: 0;
}

.overlay-buttons {
  display: flex;
  gap: 8px;
}

.hint {
  text-align: center;
  color: #9a9086;
  font-size: 14px;
}
