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

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #ffe0b2, #ffb74d);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

#stage { position: relative; width: 500px; transform-origin: center; }

#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  color: #e65100;
}
#topbar a, #topbar button {
  font-size: 20px;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: rgba(255, 255, 255, .75);
  cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(230, 81, 0, .25);
}
#topbar button:hover, #topbar a:hover { background: #fff; }

#scorebox, #bestbox {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .75);
  padding: 6px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 3px 6px rgba(230, 81, 0, .25);
}
#scorebox b, #bestbox b { font-size: 20px; color: #bf360c; }
#ctrlBtns { margin-left: auto; display: flex; gap: 8px; }

#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #d8a657;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 12px 28px rgba(230, 81, 0, .35);
  touch-action: none;
}

.cell {
  aspect-ratio: 1;
  background: #e9cba4;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.tile {
  width: 100%; height: 100%;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: clamp(20px, 7.5vw, 34px);
  animation: pop .16s ease;
}
.tile.glow { box-shadow: 0 0 14px rgba(255, 215, 64, .9); }
@keyframes pop { from { transform: scale(.6); opacity: .4; } }

#hint {
  text-align: center;
  margin-top: 12px;
  font-size: 13px; font-weight: 700;
  color: #a05a1e;
}

#overlay {
  position: absolute; inset: 44px 0 0 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(90, 45, 5, .45);
  border-radius: 16px;
}
#overlay.hidden { display: none; }

.screen {
  background: #fff;
  border-radius: 20px;
  padding: 26px 34px;
  text-align: center;
  color: #e65100;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
  animation: pop .22s ease;
}
.screen h2 { font-size: 26px; margin-bottom: 10px; }
.screen p { font-size: 14px; color: #6d4c41; margin-bottom: 16px; line-height: 1.7; }
.screen button {
  display: block; width: 220px; margin: 8px auto 0;
  padding: 10px 0;
  font-size: 15px; font-weight: 700;
  border: none; border-radius: 12px;
  background: #fff3e0; color: #e65100;
  cursor: pointer;
}
.screen button:hover { background: #ffe0b2; }
.screen button.big { background: #ff9800; color: #fff; font-size: 17px; padding: 12px 0; }
.screen button.big:hover { background: #f57c00; }
