* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #faf8ef;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  touch-action: none;
  user-select: none;
}

.container {
  width: min(92vw, 480px);
  padding: 16px 0;
}

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

h1 {
  font-size: 48px;
  color: #776e65;
}

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

.score-box {
  background: #bbada0;
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  text-align: center;
}

.score-box span {
  display: block;
  font-size: 22px;
  font-weight: bold;
}

.board-wrap {
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #bbada0;
  border-radius: 8px;
  padding: 10px;
  aspect-ratio: 1;
}

.cell {
  background: #cdc1b4;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #776e65;
  transition: background 0.15s;
}

.cell.v2    { background: #eee4da; }
.cell.v4    { background: #ede0c8; }
.cell.v8    { background: #f2b179; color: #f9f6f2; }
.cell.v16   { background: #f59563; color: #f9f6f2; }
.cell.v32   { background: #f67c5f; color: #f9f6f2; }
.cell.v64   { background: #f65e3b; color: #f9f6f2; }
.cell.v128  { background: #edcf72; color: #f9f6f2; }
.cell.v256  { background: #edcc61; color: #f9f6f2; }
.cell.v512  { background: #edc850; color: #f9f6f2; }
.cell.v1024 { background: #edc53f; color: #f9f6f2; }
.cell.v2048 { background: #edc22e; color: #f9f6f2; }
.cell.vbig  { background: #3c3a32; color: #f9f6f2; }

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

#overlay.hidden { display: none; }

#overlay p {
  font-size: 32px;
  font-weight: bold;
  color: #776e65;
}

#restart {
  background: #8f7a66;
  color: #f9f6f2;
  border: none;
  border-radius: 6px;
  padding: 12px 24px;
  font-size: 18px;
  cursor: pointer;
}

.hint {
  margin-top: 16px;
  text-align: center;
  color: #8f8579;
  font-size: 14px;
}

.home-btn {
  display: inline-block;
  margin: 8px 0 4px;
  color: #8f8579;
  text-decoration: none;
  font-size: 15px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(187, 173, 160, 0.25);
}
