/* style.css — 像素复古风格样式
 * 设计要点：限定调色板、等宽像素字体、CRT 扫描线叠加、移动端自适应。
 */

:root {
  --bg: #0b0f0a;          /* 画布背景：近黑墨绿 */
  --panel: #0f1a12;       /* 面板背景 */
  --green: #39ff14;       /* 主绿（蛇身/强调） */
  --green-soft: #aaffaa;  /* 浅绿（蛇头/副文字） */
  --red: #ff3b3b;         /* 食物红 */
  --line: #1f3d2a;        /* 描边/分割线 */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #050805;
  color: var(--green);
  /* 像素字体优先，离线回退等宽 */
  font-family: "Press Start 2P", "Courier New", monospace;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 16px;
}

.game-shell {
  width: 100%;
  max-width: 420px;
}

/* ---- 顶部 ---- */
.game-header {
  text-align: center;
  margin-bottom: 12px;
}
.game-title {
  font-size: 22px;
  letter-spacing: 2px;
  text-shadow: 0 0 8px var(--green);
  margin: 8px 0;
}
.score-board {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 12px;
  color: var(--green-soft);
}
.score-board b { color: #fff; }

/* ---- 舞台 ---- */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;   /* 正方形，随宽度缩放 */
  margin: 0 auto;
  border: 4px solid var(--line);
  background: var(--bg);
  overflow: hidden;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges; /* Firefox 像素化 */
  image-rendering: pixelated;   /* Chrome/标准：放大保持锐利像素 */
}
/* CRT 扫描线叠加 */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.25) 3px,
    rgba(0, 0, 0, 0.25) 4px
  );
}

/* ---- 覆盖层 ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(5, 8, 5, 0.92);
  z-index: 2;
}
.overlay.hidden { display: none; }
.overlay h2 {
  font-size: 18px;
  color: var(--green);
  text-shadow: 0 0 8px var(--green);
  margin: 0;
}
.overlay p { font-size: 10px; color: var(--green-soft); line-height: 1.8; margin: 0; }
.overlay p b { color: #fff; font-size: 14px; }
.tip { opacity: 0.85; }

/* 最近记录列表 */
.records {
  width: 80%;
  max-height: 40%;
  overflow-y: auto;
  border-top: 2px dashed var(--line);
  padding-top: 8px;
}
.records h3 { font-size: 11px; margin: 0 0 8px; color: var(--green); }
.records ol {
  list-style: decimal inside;
  margin: 0;
  padding: 0;
  font-size: 9px;
  color: var(--green-soft);
  line-height: 2;
}

/* ---- 按钮 ---- */
.pixel-btn {
  font-family: inherit;
  font-size: 11px;
  color: #050805;
  background: var(--green);
  border: 2px solid #fff;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.05s ease;
}
.pixel-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---- 分享区 ---- */
#share-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
#share-area canvas {
  image-rendering: pixelated;
  border: 2px solid var(--line);
}

/* ---- 底部 ---- */
.game-footer {
  text-align: center;
  font-size: 8px;
  color: #4f7a5a;
  margin-top: 10px;
  line-height: 1.6;
}

/* ---- 分享覆盖层（微信长按保存模式） ---- */
.share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.share-overlay.active { display: flex; }
.share-card-img {
  max-width: 90vw;
  max-height: 70vh;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(57, 255, 20, 0.25);
  object-fit: contain;
}
.share-hint {
  color: #7fbf7f;
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
}
.share-close {
  color: #aaffaa;
  background: rgba(57, 255, 20, 0.1);
  border: 1px solid rgba(57, 255, 20, 0.4);
  padding: 10px 32px;
  border-radius: 24px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 16px;
}
