/* 贪吃蛇 */
* { 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, #81d4fa, #4fc3f7);
  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: #01579b;
}
#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(1, 87, 155, .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(1, 87, 155, .25);
}
#scorebox b, #bestbox b { font-size: 20px; color: #e65100; }
#ctrlBtns { margin-left: auto; display: flex; gap: 8px; }

#board {
  display: block;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(1, 87, 155, .35);
  touch-action: none;
}

/* 手机方向键 */
#dpad {
  display: none;
  grid-template-areas: ". u ." "l d r";
  gap: 6px;
  width: 168px;
  margin: 12px auto 0;
}
#dpad button {
  height: 48px;
  border: none; border-radius: 12px;
  font-size: 20px;
  background: rgba(255, 255, 255, .75);
  box-shadow: 0 3px 6px rgba(1, 87, 155, .25);
  cursor: pointer;
}
#dpad button:active { background: #fff; transform: scale(.94); }

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

.screen {
  background: #fff;
  border-radius: 20px;
  padding: 26px 34px;
  text-align: center;
  color: #01579b;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
  animation: pop .22s ease;
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
.screen h2 { font-size: 26px; margin-bottom: 10px; }
.screen p { font-size: 14px; color: #456; margin-bottom: 16px; line-height: 1.7; }
.screen button {
  display: block; width: 200px; margin: 8px auto 0;
  padding: 10px 0;
  font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px;
  background: #e1f5fe; color: #01579b;
  cursor: pointer;
}
.screen button:hover { background: #b3e5fc; }
.screen button.big { background: #29b6f6; color: #fff; font-size: 18px; padding: 12px 0; }
.screen button.big:hover { background: #0aa2e0; }

@media (pointer: coarse) {
  #dpad { display: grid; }
}
