/* ===== Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
  color: #222;
  background: #fafafa;
}

/* ===== Nav ===== */
nav { display: flex; gap: 20px; margin-bottom: 20px; align-items: center; }
nav .logo { font-weight: bold; font-size: 1.2em; text-decoration: none; color: #333; }
nav a { text-decoration: none; color: #666; }

/* ===== Headings ===== */
h1 { font-size: 1.6em; margin-bottom: 16px; }
.content h2 { margin-top: 30px; font-size: 1.2em; }

/* ===== Game area: desktop left/right ===== */
.game-container { display: flex; gap: 20px; margin: 20px 0; align-items: flex-start; overflow: hidden; position: relative; }
#pixel-canvas { image-rendering: pixelated; background: #fff; display: block; }
#grid-wrapper { border: 2px solid #333; box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform-origin: top left; touch-action: none; }

/* ===== Palette ===== */
.color-palette { display: flex; flex-direction: column; gap: 10px; }
.color-swatch {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none; padding: 0; cursor: pointer;
  background: #e3e3e3;            /* 进度环底色（由 JS 用 conic-gradient 覆盖） */
  transition: transform 0.18s ease;
  outline: none;
}
.color-swatch .swatch-color {
  position: absolute; inset: 5px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.color-swatch .swatch-count {
  position: absolute; right: -2px; bottom: -2px;
  background: #333; color: #fff;
  font-size: 10px; line-height: 1; font-weight: 700;
  padding: 2px 4px; border-radius: 9px;
  min-width: 18px; text-align: center;
  pointer-events: none;
}
.color-swatch.active { transform: scale(1.16) translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.25); }
.color-swatch.completed .swatch-color { opacity: 0.4; }
.color-swatch.completed .swatch-count { background: #4CAF50; }

/* ===== Number overlay (color by number) ===== */
.num-label {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  color: #9aa0a6; font-weight: 700;
  pointer-events: none;
  user-select: none;
}
.num-label.highlight {
  color: #444;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
}

/* ===== Confetti + win modal ===== */
.confetti {
  position: fixed; top: -12px;
  width: 8px; height: 8px;
  z-index: 9999; pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(106vh) rotate(720deg); opacity: 0; }
}
.win-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35); z-index: 10000;
}
.win-modal .box {
  background: #fff; padding: 28px 40px; border-radius: 14px;
  text-align: center; font-size: 1.5em; font-weight: 700; color: #333;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}

/* ===== Buttons ===== */
.controls { display: flex; gap: 10px; margin: 15px 0; }
.controls button {
  padding: 10px 20px; font-size: 16px; cursor: pointer;
  border: 1px solid #ccc; border-radius: 6px; background: #f5f5f5;
}
.controls button:hover { border-color: #4CAF50; }

/* ===== Progress ===== */
.progress-bar { width: 100%; height: 12px; background: #eee; border-radius: 6px; margin: 10px 0; overflow: hidden; }
.progress-fill { height: 100%; background: #4CAF50; border-radius: 6px; width: 0%; transition: width 0.3s; }
#progress-text { font-size: 14px; color: #666; }

/* ===== Pattern gallery (card view) ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.pattern-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 10px;
  background: #fff; border: 2px solid #eee; border-radius: 12px;
  cursor: pointer; text-decoration: none; color: #333;
  font: inherit; text-align: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pattern-card:hover {
  transform: translateY(-3px);
  border-color: #4CAF50;
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}
.pattern-card.active {
  border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.25);
}
.card-preview {
  width: 112px; height: 112px;
  image-rendering: pixelated;
  border-radius: 8px; border: 1px solid #f0f0f0; background: #fff;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-colors { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.08); }

/* ===== Content ===== */
.content { max-width: 700px; margin: 40px auto; line-height: 1.8; }
.content p { margin: 10px 0; }
.content details { margin: 8px 0; padding: 8px 12px; border: 1px solid #eee; border-radius: 6px; background: #fff; }
/* 带 alt 的游戏截图：满足哥飞 "img 必须写 alt" 规则，并给首轮抓取一个真实可见图 */
.content .shot { display: block; width: 100%; max-width: 640px; height: auto; margin: 18px auto; border-radius: 12px; border: 1px solid #eee; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }

/* ===== Footer ===== */
footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid #eee; color: #999; font-size: 14px; }

/* ============================================================
   Mobile: ≤768px —— canvas fills, palette below canvas in a row
   ============================================================ */
@media (max-width: 768px) {
  .game-container { flex-direction: column; align-items: center; }
  #pixel-canvas { width: 100%; height: auto; }
  .color-palette { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .color-swatch { width: 38px; height: 38px; }
  .card-preview { width: 92px; height: 92px; }
}

/* ===== Gallery filters (audience / difficulty) ===== */
.gallery-filters { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 4px; align-items: center; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 13px; color: #888; margin-right: 2px; }
.filter-chip {
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  border: 1px solid #ddd; border-radius: 999px; background: #fff; color: #555;
  transition: all .15s ease;
}
.filter-chip:hover { border-color: #4CAF50; color: #333; }
.filter-chip.active { background: #4CAF50; border-color: #4CAF50; color: #fff; }
.pattern-card.hidden { display: none; }
.gallery-empty { color: #999; font-size: 14px; margin: 10px 0; }

/* ===== No-JS static link fallback (SEO first-crawl) ===== */
.static-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 16px 0; }
.static-links li a { color: #666; text-decoration: none; }
.static-links li a:hover { color: #333; text-decoration: underline; }

/* ===== Visible pattern index list (real static internal links) ===== */
.pattern-index { margin: 16px 0; padding-left: 22px; }
.pattern-index li { margin: 6px 0; line-height: 1.5; }
.pattern-index a { font-weight: 600; color: #c0392b; text-decoration: none; }
.pattern-index a:hover { text-decoration: underline; }
