* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #faf8ef;
  color: #776e65;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  width: min(90vw, 420px);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header h1 {
  font-size: 3rem;
  font-weight: bold;
  color: #776e65;
}

.score-box {
  background: #bbada0;
  border-radius: 6px;
  padding: 8px 20px;
  text-align: center;
  min-width: 80px;
}

.score-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #eee4da;
}

#score {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
}

.controls {
  margin-bottom: 16px;
}

button {
  background: #8f7a66;
  color: #f9f6f2;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

button:hover {
  background: #9f8b77;
}

.board-wrapper {
  position: relative;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  background: #bbada0;
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  aspect-ratio: 1;
}

.cell {
  background: rgba(238, 228, 218, 0.5);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
  min-height: 0;
  min-width: 0;
}

.tile {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: appear 0.15s ease;
}

@keyframes appear {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.tile-2    { background: #eee4da; color: #776e65; }
.tile-4    { background: #ede0c8; color: #776e65; }
.tile-8    { background: #f2b179; color: #f9f6f2; }
.tile-16   { background: #f59563; color: #f9f6f2; }
.tile-32   { background: #f67c5f; color: #f9f6f2; }
.tile-64   { background: #f65e3b; color: #f9f6f2; }
.tile-128  { background: #edcf72; color: #f9f6f2; font-size: 1.6rem; }
.tile-256  { background: #edcc61; color: #f9f6f2; font-size: 1.6rem; }
.tile-512  { background: #edc850; color: #f9f6f2; font-size: 1.6rem; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.3rem; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.3rem; }
.tile-super { background: #3c3a32; color: #f9f6f2; font-size: 1.1rem; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(238, 228, 218, 0.75);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
}

.overlay-content h2 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.overlay-content p {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.hint {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: #998;
}
