/* CSS Document */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  min-height: 100dvh;
  background: #0b0e14 url('https://shaders.skycrystal.fun/images/background.png') center/cover no-repeat fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Inter', 'Roboto', 'Work Sans', 'Avenir Next', monospace;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  padding: 16px;
  margin: 0;
}
.glass-panel {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-radius: 48px;
  padding: 24px 28px 32px 28px;
  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.7),
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    inset 0 -3px 0 rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 98vw;
  max-height: 98dvh;
  transition: all 0.3s ease;
}
.scoreboard {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 6px 18px 6px 22px;
  color: #f0f4ff;
  text-shadow: 0 2px 0 #0a0c10, 0 4px 12px rgba(0,0,0,0.7);
  font-size: clamp(18px, 3.5vmin, 36px);
  font-weight: 400;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  letter-spacing: 2px;
  flex-shrink: 0;
}
.scoreboard span:first-child {
  opacity: 0.75;
  font-size: 0.7em;
  margin-right: 6px;
}
.scoreboard .score-value {
  background: rgba(0, 0, 0, 0.3);
  padding: 0 20px;
  border-radius: 40px;
  font-size: 1.2em;
  font-weight: bold;
  color: #b7e6ff;
  text-shadow: 0 0 16px #5fb3ff80;
  border: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.4;
}
#game-wrapper {
  position: relative;
  width: min(80vmin, 600px);
  height: min(80vmin, 600px);
  min-width: 200px;
  min-height: 200px;
  flex-shrink: 0;
  flex-grow: 0;
}

#game-board {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 23, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 36px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 8px 28px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.snake-part {
  position: absolute;
  width: calc(100% / 20);
  height: calc(100% / 20);
  background: #3ba87a;
  background-image:
    repeating-linear-gradient(45deg, #2f8f64 0px, #2f8f64 2px, #4bcb94 2px, #4bcb94 4px),
    repeating-linear-gradient(-45deg, #2f8f64 0px, #2f8f64 2px, #4bcb94 2px, #4bcb94 4px);
  background-blend-mode: overlay;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.5);
  border-radius: 20% 8% 20% 8%;
  transform: scale(0.92);
  transition: transform 0.08s ease, box-shadow 0.15s;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  will-change: transform;
  animation: snakePulse 1.8s infinite alternate ease-in-out;
}
.snake-part:first-child {
  background: #4fd3a0;
  background-image:
    repeating-linear-gradient(45deg, #3aa87a 0px, #3aa87a 2px, #5fe0b0 2px, #5fe0b0 4px),
    repeating-linear-gradient(-45deg, #3aa87a 0px, #3aa87a 2px, #5fe0b0 2px, #5fe0b0 4px);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.5),
    0 0 20px #68ffc0,
    0 0 40px #68ffc060;
  border-radius: 24% 10% 24% 10%;
  transform: scale(0.96);
  z-index: 2;
  animation: headGlow 1.6s infinite alternate ease-in-out;
}

@keyframes snakePulse {
  0% { transform: scale(0.90); opacity: 0.95; }
  100% { transform: scale(0.98); opacity: 1; }
}
@keyframes headGlow {
  0% { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4), 0 0 12px #68ffc0, 0 0 30px #68ffc040; }
  100% { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.7), 0 0 28px #8effd0, 0 0 60px #68ffc080; }
}
.food {
  position: absolute;
  width: calc(100% / 20);
  height: calc(100% / 20);
  background-image: url('https://packery.skycrystal.fun/images/cake.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.7)) drop-shadow(0 0 20px #ffb07c);
  transform: scale(0.88);
  transition: transform 0.12s ease;
  border-radius: 6px;
  animation: foodFloat 1.2s infinite alternate ease-in-out;
}
.food:hover {
  transform: scale(0.96);
}
@keyframes foodFloat {
  0% { transform: scale(0.86) translateY(-2px); filter: drop-shadow(0 4px 12px #000000aa) drop-shadow(0 0 18px #ffb07c); }
  100% { transform: scale(0.94) translateY(3px); filter: drop-shadow(0 8px 20px #000000cc) drop-shadow(0 0 30px #ffaa66); }
}
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  animation: overlayFade 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.gameover-card {
  background: rgba(25, 30, 45, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 80px;
  padding: 44px 48px 52px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 40px 100px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.15);
  max-width: 440px;
  width: 90%;
  animation: cardPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.3);
}
.gameover-card h1 {
  font-size: clamp(34px, 8vw, 56px);
  margin: 0 0 6px 0;
  color: #ffb0b0;
  text-shadow: 0 4px 0 #5a1e1e, 0 0 40px #ff6a6a80;
  letter-spacing: 4px;
  font-weight: 400;
}
.gameover-card .final-score {
  font-size: clamp(22px, 4vw, 32px);
  color: #d4eaff;
  background: rgba(0,0,0,0.3);
  padding: 6px 28px;
  border-radius: 60px;
  display: inline-block;
  margin: 8px 0 28px 0;
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(4px);
}
.gameover-card button {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  font-size: clamp(22px, 4vw, 30px);
  font-family: inherit;
  padding: 12px 40px;
  border-radius: 80px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  letter-spacing: 3px;
  text-shadow: 0 2px 0 #0a0c10;
}
.gameover-card button:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px #5fb3ff50;
}
.gameover-card button:active {
  transform: scale(0.94);
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cardPop {
  0% { transform: scale(0.75) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-aspect-ratio: 1/1) {
  .glass-panel {
    padding: 14px 14px 18px 14px;
    border-radius: 32px;
  }
  #game-wrapper {
    width: min(85vw, 450px);
    height: min(85vw, 450px);
    min-width: 160px;
    min-height: 160px;
  }
  .scoreboard {
    font-size: clamp(14px, 4vw, 22px);
    padding: 4px 12px 4px 16px;
    margin-bottom: 10px;
  }
}
@media (min-aspect-ratio: 1/1) {
  .glass-panel {
    padding: 18px 22px 22px 22px;
    border-radius: 48px;
  }
  #game-wrapper {
    width: min(75vh, 600px);
    height: min(75vh, 600px);
    min-width: 240px;
    min-height: 240px;
  }
  .scoreboard {
    font-size: clamp(16px, 3vh, 30px);
    padding: 6px 18px 6px 22px;
    margin-bottom: 12px;
  }
}

<<<<<<< HEAD

=======
/* 极小屏优化 */
>>>>>>> d9ea78c9973fe2ba7fbde74c0e324cf8e688f08d
@media (max-width: 420px) {
  .glass-panel { padding: 10px 10px 14px 10px; border-radius: 24px; }
  #game-wrapper {
    width: min(88vw, 300px);
    height: min(88vw, 300px);
    min-width: 130px;
    min-height: 130px;
  }
  .scoreboard { font-size: 12px; padding: 2px 8px; }
}
