:root {
  color-scheme: light;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: #faf8ef;
  color: #776e65;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overscroll-behavior: none;
  touch-action: none;
}

.game {
  width: min(92vw, 500px);
  margin: 0 auto;
  padding: 24px 0 36px;
}

.heading, .intro, .scores {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  color: #776e65;
  font-size: clamp(54px, 16vw, 80px);
  line-height: .9;
}

.scores { justify-content: flex-end; }

.score-box {
  min-width: 72px;
  padding: 7px 12px;
  border-radius: 4px;
  background: #bbada0;
  color: #fff;
  text-align: center;
}

.score-box span {
  display: block;
  color: #eee4da;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.score-box strong { font-size: 24px; }

.intro { margin: 24px 0; }
.intro p { margin: 0; font-size: 17px; }

button {
  flex: none;
  border: 0;
  border-radius: 4px;
  padding: 11px 16px;
  background: #8f7a66;
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid #f9a825; outline-offset: 3px; }

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(7px, 2.5vw, 15px);
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(7px, 2.5vw, 15px);
  border-radius: 7px;
  background: #bbada0;
  user-select: none;
  -webkit-user-select: none;
}

.tile {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border-radius: 4px;
  background: rgba(238, 228, 218, .35);
  color: #776e65;
  font-size: clamp(25px, 9vw, 55px);
  font-weight: 800;
  line-height: 1;
}

.tile[data-value="2"] { background: #eee4da; }
.tile[data-value="4"] { background: #ede0c8; }
.tile[data-value="8"] { background: #f2b179; color: #f9f6f2; }
.tile[data-value="16"] { background: #f59563; color: #f9f6f2; }
.tile[data-value="32"] { background: #f67c5f; color: #f9f6f2; }
.tile[data-value="64"] { background: #f65e3b; color: #f9f6f2; }
.tile[data-value="128"] { background: #edcf72; color: #f9f6f2; font-size: clamp(21px, 7vw, 45px); }
.tile[data-value="256"] { background: #edcc61; color: #f9f6f2; font-size: clamp(21px, 7vw, 45px); }
.tile[data-value="512"] { background: #edc850; color: #f9f6f2; font-size: clamp(21px, 7vw, 45px); }
.tile[data-value="1024"] { background: #edc53f; color: #f9f6f2; font-size: clamp(17px, 5.7vw, 36px); }
.tile[data-value="2048"] { background: #edc22e; color: #f9f6f2; font-size: clamp(17px, 5.7vw, 36px); }
.tile.super { background: #3c3a32; color: #f9f6f2; font-size: clamp(15px, 5vw, 32px); }

.status {
  min-height: 1.5em;
  margin: 14px 0 0;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}

.instructions { margin: 18px 0; line-height: 1.5; }

footer {
  padding-top: 16px;
  border-top: 1px solid #d8d4cc;
  font-size: 13px;
  line-height: 1.5;
}

a { color: #776e65; }

@media (max-width: 420px) {
  .game { padding-top: 16px; }
  .heading { align-items: flex-end; }
  .score-box { min-width: 62px; padding-inline: 8px; }
  .score-box strong { font-size: 20px; }
  .intro { align-items: flex-start; }
}
