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

body {
  background: #faf8ef;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #776e65;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#header h1 {
  font-size: 3rem;
  font-weight: 800;
}

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

.score-box {
  background: #bbada0;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  text-align: center;
  min-width: 70px;
}

.score-box .label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
}

.score-box span:last-child {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
}

#grid-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #bbada0;
  padding: 12px;
  border-radius: 10px;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
}

.cell {
  background: #cdc1b4;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  transition: transform 0.1s;
}

.cell[data-value] { background: #eee4da; }
.cell[data-value="2"] { background: #eee4da; }
.cell[data-value="4"] { background: #ede0c8; }
.cell[data-value="8"] { background: #f2b179; color: white; }
.cell[data-value="16"] { background: #f59563; color: white; }
.cell[data-value="32"] { background: #f67c5f; color: white; }
.cell[data-value="64"] { background: #f65e3b; color: white; }
.cell[data-value="128"] { background: #edcf72; color: white; font-size: 1.7rem; }
.cell[data-value="256"] { background: #edcc61; color: white; font-size: 1.7rem; }
.cell[data-value="512"] { background: #edc850; color: white; font-size: 1.7rem; }
.cell[data-value="1024"] { background: #edc53f; color: white; font-size: 1.4rem; }
.cell[data-value="2048"] { background: #edc22e; color: white; font-size: 1.4rem; box-shadow: 0 0 20px rgba(237, 194, 46, 0.5); }

#ad-banner {
  height: 60px;
  margin-top: 12px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(238, 228, 218, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden { display: none; }

.overlay-content {
  text-align: center;
  background: white;
  padding: 32px 48px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.overlay-content h2 { font-size: 2.5rem; margin-bottom: 12px; }
.overlay-content p { font-size: 1.2rem; margin-bottom: 20px; }

.overlay-content button {
  display: block;
  width: 100%;
  padding: 14px 24px;
  margin: 8px 0;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#watch-ad-btn {
  background: #f2b179;
  color: white;
}

#watch-ad-btn:hover { background: #e89c5c; }

#restart-btn {
  background: #8f7a66;
  color: white;
}

#restart-btn:hover { background: #776055; }
