/* ==========================================================================
   贪吃蛇 — 样式表
   轻量级、响应式、无障碍优先，街机主题
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  line-height: 1.5;
  tab-size: 4;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans SC", sans-serif;
  background: #0f172a;
  color: #f8fafc;
  font-size: 1rem;
}

a {
  color: inherit;
  text-decoration: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: -1;
}

.skip-link:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  background: #000;
  color: #fff;
  z-index: 10000;
  border-radius: 0.25rem;
  text-decoration: underline;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.breadcrumb {
  padding-top: 1rem;
  font-size: 0.85rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #94a3b8;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.breadcrumb li + li::before {
  content: "/";
  color: #64748b;
}

.breadcrumb a {
  color: #cbd5e1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.breadcrumb a:hover {
  color: #6ee7b7;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.12em 0.4em;
  border: 1px solid #475569;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #1e293b;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.82em;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.section {
  padding: 3rem 0;
}

.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-header h2 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
  color: #f8fafc;
}

.section-desc {
  margin: 0;
  color: #94a3b8;
  font-size: 1rem;
}

:focus-visible {
  outline: 3px solid #10b981;
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid #334155;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: #f8fafc;
}

.brand-icon {
  width: 1.5rem;
  height: 1.5rem;
}

.main-nav {
  min-width: 0;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: inline-block;
  font-weight: 500;
  color: #cbd5e1;
  padding: 0.4rem 0.6rem;
  border-radius: 0.35rem;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover, .nav-link:focus-visible {
  color: #10b981;
  background: #1e293b;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, background 0.2s, border-color 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #047857;
  color: #ffffff;
  border-color: #047857;
}

.btn-primary:hover {
  background: #065f46;
  border-color: #065f46;
}

.btn-outline {
  background: transparent;
  color: #10b981;
  border-color: #10b981;
}

.btn-outline:hover {
  background: #10b981;
  color: #ffffff;
}

.btn-lg {
  padding: 0.8rem 1.75rem;
  font-size: 1.1rem;
}

.hero {
  padding: 4rem 0 5rem;
  background: radial-gradient(circle at center, #064e3b 0%, #0f172a 60%, #020617 100%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  color: #f8fafc;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #34d399, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lede {
  font-size: 1.125rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin: 0 0 1.75rem;
  max-width: 480px;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.hero-stats {
  display: flex;
  gap: 1.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #10b981;
}

.stat-label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.snake-preview {
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
}

.preview-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  width: 100%;
  aspect-ratio: 1;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(16, 185, 129, 0.13), transparent 55%),
    repeating-linear-gradient(0deg, rgba(148, 163, 184, 0.08) 0 1px, transparent 1px 12.5%),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.08) 0 1px, transparent 1px 12.5%),
    #111c31;
  box-shadow: 0 24px 50px -24px rgba(16, 185, 129, 0.45), inset 0 0 0 1px rgba(148, 163, 184, 0.06);
}

.seg {
  border-radius: 6px;
  background: linear-gradient(145deg, #34d399, #059669);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.seg-1 { grid-area: 5 / 1; }
.seg-2 { grid-area: 5 / 2; }
.seg-3 { grid-area: 5 / 3; }
.seg-4 { grid-area: 4 / 3; }
.seg-5 { grid-area: 3 / 3; }
.seg-6 { grid-area: 3 / 4; }

.seg-head {
  position: relative;
  grid-area: 3 / 5;
  background: linear-gradient(145deg, #6ee7b7, #10b981);
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.55);
}

.seg-head::before,
.seg-head::after {
  content: "";
  position: absolute;
  top: 26%;
  width: 17%;
  height: 17%;
  border-radius: 50%;
  background: #052e1b;
}

.seg-head::before { left: 20%; }
.seg-head::after { right: 20%; }

.preview-food {
  grid-area: 3 / 7;
  align-self: center;
  justify-self: center;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fca5a5, #ef4444 55%, #b91c1c);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.55);
}

.steps {
  display: grid;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #1e293b;
}

.step-num {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
}

.step-body h3 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  color: #f8fafc;
}

.step-body p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
}

.game-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #1e293b;
  justify-content: center;
}

.hud {
  display: flex;
  gap: 1.5rem;
  font-weight: 600;
  color: #cbd5e1;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
}

.hud-label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-value {
  font-size: 1.25rem;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

canvas {
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  max-width: 100%;
  height: auto;
}

canvas:focus-visible {
  outline: 3px solid #10b981;
  outline-offset: 3px;
}

.controls-touch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.dir-row {
  display: flex;
  gap: 0.5rem;
}

.dir-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}

.dir-btn:active {
  background: #10b981;
  border-color: #10b981;
}

.dir-btn:focus-visible {
  outline: 3px solid #10b981;
  outline-offset: 2px;
}

.game-message {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.6rem;
  background: #450a0a;
  color: #fecaca;
  text-align: center;
  font-weight: 600;
  display: none;
  border: 1px solid #7f1d1d;
}

.game-message[hidden] { display: none; }

.game-message.win { background: #064e3b; border-color: #22c55e; color: #86efac; }

.game-help {
  max-width: 620px;
  margin: 1rem auto 0;
  color: #94a3b8;
  font-size: 0.82rem;
  line-height: 1.65;
  text-align: center;
}

.noscript {
  margin: 1rem auto 0;
  padding: 0.85rem 1rem;
  max-width: 620px;
  border: 1px solid #92400e;
  border-radius: 0.6rem;
  background: #451a03;
  color: #fde68a;
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: center;
}

.feature-list {
  display: grid;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.feature-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #1e293b;
}

.feature-icon {
  flex-shrink: 0;
  font-size: 1.75rem;
}

.feature-item h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: #f8fafc;
}

.feature-item p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
}

.faq-item {
  border: 1px solid #334155;
  border-radius: 0.6rem;
  overflow: hidden;
  background: #1e293b;
}

.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: #f8fafc;
  list-style: none;
  cursor: pointer;
  outline: none;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item p {
  margin: 0;
  padding: 0 1.25rem 1rem;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
}

.site-footer {
  border-top: 1px solid #334155;
  background: #0f172a;
  padding: 2.5rem 0;
  margin-top: 3rem;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  align-items: center;
}

.footer-brand .brand-text {
  font-weight: 700;
  font-size: 1.125rem;
  color: #f8fafc;
}

.footer-tagline {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.95rem;
  max-width: 520px;
}

.footer-links a {
  color: #94a3b8;
  font-size: 0.9rem;
}

.footer-links a:hover,
.footer-links a:focus-visible { color: #6ee7b7; }

.footer-note p {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: 0.4rem; }
  .main-nav { width: 100%; }
  .nav-list { justify-content: flex-start; gap: 0.1rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .hero { padding: 2.5rem 0 3.5rem; }
  .snake-preview { max-width: 270px; }
  .footer-grid { flex-direction: column; text-align: center; align-items: center; }
  .footer-links { justify-content: center; }
  canvas { width: 100%; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .btn-primary { ButtonBorder: ButtonText; ButtonFace: ButtonText; }
  canvas { border: 1px solid ButtonText; }
}