/* Snake_Game_Python — browser edition */
:root {
  --bg: #0f0f14;
  --accent: #4ade80;
  --accent-deep: #22c55e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  width: 100%;
  height: 100%;
  /* Respect mobile safe areas (notches) when embedded full-bleed. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The canvas's backing store is sized by devicePixelRatio in JS (so it stays
   crisp on high-DPI screens), which also gives it a natural 672:782 aspect
   ratio. max-width/height then scale it down to "contain" within the viewport
   exactly like an image — preserving the ratio in both portrait and landscape.
   The game maps pointer coordinates back to its internal grid. */
#game {
  display: block;
  background: var(--bg);
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  image-rendering: auto;
}

noscript {
  color: #ececf1;
  display: block;
  text-align: center;
  margin-top: 2rem;
}

/* -- Loading splash -------------------------------------------------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 38%, #161620 0%, var(--bg) 70%);
  transition: opacity 0.45s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }

.loader-snake { display: flex; gap: 8px; }
.loader-snake span {
  width: 16px; height: 16px; border-radius: 5px;
  background: var(--accent);
  animation: loader-pulse 1s ease-in-out infinite;
}
.loader-snake span:nth-child(2) { animation-delay: 0.12s; opacity: 0.85; }
.loader-snake span:nth-child(3) { animation-delay: 0.24s; opacity: 0.7; }
.loader-snake span:nth-child(4) { animation-delay: 0.36s; opacity: 0.55; }
@keyframes loader-pulse {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-12px); }
}

.loader-title {
  font-size: 34px; font-weight: 700; letter-spacing: 10px;
  color: #ececf1; padding-left: 10px;
}
.loader-bar {
  width: 220px; height: 6px; border-radius: 3px;
  background: #2a2a36; overflow: hidden;
}
.loader-bar i {
  display: block; height: 100%; width: 40%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  animation: loader-slide 1.1s ease-in-out infinite;
}
@keyframes loader-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.loader-tip { color: #8a8a99; font-size: 14px; letter-spacing: 1px; }
