/* ===== 贪吃蛇 ===== */
.canvas-wrap {
  position: relative;
  width: min(92vw, 440px);
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
  border-radius: 20px;
  overflow: hidden;
  background: #1e2a3a;
  box-shadow: 0 16px 38px rgba(30, 42, 58, .3);
  touch-action: none;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 开始前的遮罩 */
.start-mask {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(30, 42, 58, .82);
  color: #fff;
  text-align: center;
  padding: 20px;
  transition: opacity .3s;
}

.start-mask.hide { opacity: 0; pointer-events: none; }

.mask-title { font-size: 24px; font-weight: 900; }

.mask-hint { font-size: 14px; line-height: 1.9; color: rgba(255, 255, 255, .8); }

/* 手机方向键 */
.dpad {
  display: none;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 60px);
  gap: 8px;
  margin-bottom: 18px;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(120, 90, 150, .16);
  transition: .12s;
  user-select: none;
}

.dpad-btn:active { transform: scale(.92); background: #ffe0c2; }

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }

/* 触屏设备才显示方向键 */
@media (hover: none) and (pointer: coarse) {
  .dpad { display: grid; }
}
