body {
  font-family: sans-serif;
  text-align: center;
  background: #faf8ef;
  margin-top: 40px;
}

#game-board {
  position: relative;
  width: 75vmin; 
  height: 75vmin;
  margin: 20px auto;
  background: #bbada0;
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(4, 80px);
  grid-template-rows: repeat(4, 80px);
  gap: 10px;
  justify-content: center;
}

.tile {
  position: absolute;
  width: 80px;
  height: 80px;
  background: #cdc1b4;
  font-size: 24px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  color: #776e65;
  transition: all 0.15s ease-in-out;
}

.tile-0 { background: #cdc1b4; }
.tile-2 { background: #eee4da; }
.tile-4 { background: #ede0c8; }
.tile-8 { background: #f2b179; color: white; }
.tile-16 { background: #f59563; color: white; }
.tile-32 { background: #f67c5f; color: white; }
.tile-64 { background: #f65e3b; color: white; }
.tile-128 { background: #edcf72; color: white; }
.tile-256 { background: #edcc61; color: white; }
.tile-512 { background: #edc850; color: white; }
.tile-1024 { background: #edc53f; color: white; }
.tile-2048 { background: #edc22e; color: white; }

#overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(238, 228, 218, 0.9);
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

#overlay.hidden {
  display: none;
}

#overlay p {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 15px;
}

#overlay button {
  background: #8f7a66;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#overlay button:hover {
  background: #9c8572;
}

#controls {
  position: fixed;
  bottom: 20px;      /* 画面下からの距離 */
  right: 20px;       /* 画面右からの距離 */
  display: grid;
  grid-template-areas:
    ". up ."
    "left down right";
  grid-gap: 10px;
  background: rgba(0, 0, 0, 0.2); /* 半透明 */
  padding: 10px;
  border-radius: 12px;
  z-index: 1000; /* 常に前面に */
}

#controls button {
  width: 50px;
  height: 50px;
  font-size: 20px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background: #8f7a66;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

#controls button:hover {
  background: #9c8572;
}

/* ボタンをグリッドに割り当て */
#controls button[data-dir="up"]    { grid-area: up; }
#controls button[data-dir="left"]  { grid-area: left; }
#controls button[data-dir="down"]  { grid-area: down; }
#controls button[data-dir="right"] { grid-area: right; }

