/* 开源商用字体 JetBrains Mono（SIL OFL 1.1，许可见 fonts/OFL.txt） */
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #1a1025;
  --panel: rgba(28, 18, 40, 0.92);
  --line: rgba(255, 180, 200, 0.18);
  --text: #f7e8f0;
  --dim: #b89cb0;
  --pink: #ff7aa2;
  --mint: #7ef0c0;
  --gold: #ffd166;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1640 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "JetBrains Mono", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 防止 iOS 双指缩放干扰游戏 */
  touch-action: manipulation;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 12px;
}

.topbar {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 14px var(--pink);
}

.brand .tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--pink);
  border: 1px solid rgba(255, 122, 162, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

button {
  cursor: pointer;
  border: 1px solid rgba(255, 180, 200, 0.28);
  background: rgba(255, 122, 162, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 9px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button:hover {
  border-color: rgba(255, 122, 162, 0.7);
  background: rgba(255, 122, 162, 0.2);
}

.stage {
  position: relative;
  width: min(420px, 100%);
  aspect-ratio: 400 / 600;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 122, 162, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.6) inset;
  /* 关键：阻止浏览器的 touch 手势干扰游戏内的 canvas 触控 */
  touch-action: none;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #231433 0%, #1a0f26 100%);
}

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score b { color: var(--gold); font-size: 18px; margin-left: 4px; }
.best b { color: var(--mint); margin-left: 4px; }

.hud-right {
  display: flex;
  align-items: flex-start;
}

.preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.preview .label {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.08em;
}

#next-fruit {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(230, 200, 220, 0.55);
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

/* 蒙层 */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.overlay.show { display: flex; }

.panel {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 122, 162, 0.22);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.panel h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: 0.04em; }
.panel .line { margin: 6px 0; font-size: 14px; }
.panel .line.dim { color: var(--dim); font-size: 12px; }

.panel button {
  margin-top: 16px;
  padding: 9px 22px;
  border-color: rgba(255, 122, 162, 0.55);
  background: rgba(255, 122, 162, 0.18);
}

.foot {
  width: min(420px, 100%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  text-align: center;
  font-size: 11px;
  color: rgba(200, 180, 200, 0.6);
}

.foot-links { display: flex; gap: 12px; }
.foot-links a { color: var(--pink); text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .app { padding: 8px 6px 16px; gap: 8px; }
  .brand .tag { display: none; }
}

/* SEO：视觉隐藏的 h1（Canvas 页不放显式大标题，但需要文档标题结构） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
