/* 贪吃蛇 —— 深色现代主题，纯 CSS，无框架 */

:root {
  --bg: #0b0e14;
  --bg-2: #10151f;
  --panel: #151c2a;
  --border: #232d3f;
  --text: #e6edf3;
  --muted: #8b96a5;
  --accent: #51cf66;
  --accent-dark: #2f9e44;
  --danger: #ff6b6b;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(81, 207, 102, 0.12), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(47, 158, 68, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 520px;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ---- 顶部标题 + 分数 ---- */
.top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }

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

.score-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.score-box span { color: var(--accent); font-weight: 700; font-size: 16px; }

/* ---- 游戏棋盘 ---- */
.board {
  position: relative;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
  touch-action: none;      /* 禁止手势缩放/滚动干扰 */
  user-select: none;
  -webkit-user-select: none;
}

.board canvas { display: block; width: 100%; height: auto; }

.status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: rgba(11, 14, 20, 0.72);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.status.show { opacity: 1; }

/* ---- 触摸方向键（仅触屏设备显示） ---- */
.controls { display: none; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
}

.pad-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  font-size: 18px;
  border-radius: 12px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad-btn:active { background: #1c2740; transform: scale(0.95); }
.pad-btn.up    { grid-column: 2; grid-row: 1; }
.pad-btn.down  { grid-column: 2; grid-row: 3; }
.pad-btn.left  { grid-column: 1; grid-row: 2; }
.pad-btn.right { grid-column: 3; grid-row: 2; }

@media (pointer: coarse) {
  .controls { display: flex; justify-content: center; width: 100%; }
}

/* ---- 重新开始按钮 ---- */
.restart {
  font-size: 16px;
  font-weight: 600;
  color: #08130b;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: 12px;
  padding: 12px 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(81, 207, 102, 0.25);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.restart:active { transform: scale(0.96); }

/* ---- 页脚 ---- */
.foot {
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.foot a { color: var(--accent); text-decoration: none; }
