/* ===== NUMBER SNAKE - Kid Friendly Theme (scoped, site-safe) ===== */
.snake-stage, .snake-stage * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.snake-stage h1, .snake-stage h2, .snake-stage p { margin: 0; padding: 0; }
.snake-stage {
  font-family: 'Comic Neue', 'Bubblegum Sans', cursive;
  background: linear-gradient(180deg, #063d1f 0%, #0d7a3f 45%, #4cc36e 80%, #c9f5a3 100%);
  border-radius: 24px; user-select: none; padding: 8px;
}
#snake-container { display: flex; flex-direction: column; min-height: max(560px, min(96vh, 960px)); max-width: 1100px; margin: 0 auto; padding: 8px; gap: 8px; }
#snake-container button { font-family: inherit; }
#snake-container .game-header, #snake-container .game-main, #snake-container .game-footer { margin: 0; }

.game-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.94); border-radius: 22px; padding: 8px 16px;
  border: 4px solid #fff; box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 10px 30px rgba(0,0,0,0.25);
  flex-wrap: wrap;
}
.game-title {
  font-family: 'Bubblegum Sans', cursive; font-size: 1.6rem; letter-spacing: 1px;
  background: linear-gradient(90deg,#22cc66,#a3e635,#ffd93d,#ff9a3d,#ff6bcb);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbowText 4s linear infinite;
}
@keyframes rainbowText { to { background-position: 300% 0; } }
.level-badge {
  display: inline-block; background: linear-gradient(135deg,#0d7a3f,#4cc36e); color: #fff;
  font-weight: bold; padding: 2px 14px; border-radius: 20px; margin-top: 4px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.2);
}
.target-badge {
  display: flex; align-items: center; gap: 10px; background: linear-gradient(135deg,#f0fdf4,#bbf7d0);
  border: 3px solid #22cc66; border-radius: 18px; padding: 4px 16px 4px 10px;
  box-shadow: 0 4px 0 #15803d;
}
.target-label { font-weight: bold; font-size: 0.8rem; color: #15803d; }
.target-letter {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 52px; padding: 0 8px;
  font-family: 'Bubblegum Sans'; font-size: 2rem; color: #fff;
  background: linear-gradient(180deg,#4cc36e,#15803d); border-radius: 14px;
  box-shadow: 0 4px 0 #14532d; animation: targetPulse 1s infinite;
}
@keyframes targetPulse { 0%,100%{transform:scale(1) rotate(-2deg);} 50%{transform:scale(1.1) rotate(2deg);} }
.stats-bar { display: flex; gap: 16px; }
.stat { display: flex; align-items: center; gap: 6px; font-weight: bold; color: #1a1a3a; }
.stat-icon { font-size: 1.35rem; animation: bounce 1.5s ease-in-out infinite; }
.stat:nth-child(2) .stat-icon { animation-delay: 0.2s; } .stat:nth-child(3) .stat-icon { animation-delay: 0.4s; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.stat-label { font-size: 0.62rem; opacity: 0.6; letter-spacing: 1px; }
.stat-value { font-size: 1.35rem; font-family: 'Bubblegum Sans'; min-width: 36px; }
.lives-container { display: flex; gap: 2px; font-size: 1.25rem; }
.lives-container .lost { filter: grayscale(1); opacity: 0.3; transform: scale(0.8); }
.header-left, .header-right { display: flex; flex-direction: column; }
.header-center { flex: 1; display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-right { flex-direction: row; gap: 14px; }

.game-main { position: relative; flex: 1; border-radius: 24px; overflow: hidden;
  border: 5px solid #fff; box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  background: #0d7a3f;
  min-height: 520px;
}
#snake-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#snake-canvas.shake { animation: nShake 0.35s; }
@keyframes nShake { 0%,100%{transform:translate(0,0);} 20%{transform:translate(-8px,4px);} 40%{transform:translate(7px,-5px);} 60%{transform:translate(-5px,-3px);} 80%{transform:translate(4px,3px);} }
#level-banner.hidden { display: none; }
#level-banner.pop { animation: bannerPop 0.5s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes bannerPop { 0% { transform: translateX(-50%) scale(0.4); } 100% { transform: translateX(-50%) scale(1); } }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4,40,20,0.74); backdrop-filter: blur(6px); z-index: 20; padding: 16px;
  opacity: 1; transition: opacity 0.3s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-content {
  background: linear-gradient(160deg, #fff 0%, #f0fdf4 100%); border-radius: 28px; padding: 26px 32px;
  text-align: center; max-width: 560px; width: 100%; max-height: 92%; overflow-y: auto;
  border: 5px solid #22cc66; box-shadow: 0 12px 0 rgba(0,0,0,0.2), 0 20px 60px rgba(0,0,0,0.4);
  animation: overlayPop 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes overlayPop { 0% { transform: scale(0.5) rotate(-4deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.overlay-content h2 { font-family: 'Bubblegum Sans'; font-size: 2.1rem; color: #15803d; margin-bottom: 6px; }
.subtitle { font-size: 1.05rem; color: #666; } .instruction { font-size: 1.2rem; font-weight: bold; color: #d63d8f; margin: 8px 0 12px; }
.mode-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.mode-btn { border: 3px solid #bbf7d0; background: #f0fdf4; border-radius: 16px; padding: 10px; font-family: inherit;
  font-weight: bold; font-size: 0.95rem; cursor: pointer; transition: all 0.15s; color: #15803d; }
.mode-btn:hover { transform: translateY(-2px) scale(1.03); border-color: #22cc66; }
.mode-btn.active { background: linear-gradient(135deg,#22cc66,#4cc36e); color: #fff; border-color: #14532d;
  box-shadow: 0 4px 0 #14532d; transform: scale(1.03); }
.difficulty-selector { margin: 10px 0; font-weight: bold; color: #555; }
.difficulty-selector select { font-family: inherit; font-weight: bold; font-size: 1rem; padding: 8px 12px;
  border-radius: 12px; border: 3px solid #22cc66; background: #fff; cursor: pointer; }
.start-btn, .resume-btn {
  font-family: 'Bubblegum Sans'; font-size: 1.55rem; letter-spacing: 2px; color: #fff; border: none; cursor: pointer;
  background: linear-gradient(180deg,#6bff8f,#22cc66); padding: 12px 44px; border-radius: 50px; margin-top: 12px;
  box-shadow: 0 6px 0 #159a4c, 0 10px 20px rgba(0,0,0,0.3); transition: all 0.12s;
  animation: btnGlow 1.6s ease-in-out infinite;
}
@keyframes btnGlow { 0%,100%{ box-shadow: 0 6px 0 #159a4c, 0 0 15px #6bff8f;} 50%{ box-shadow: 0 6px 0 #159a4c, 0 0 35px #6bff8f;} }
.start-btn:hover, .resume-btn:hover { transform: translateY(-3px) scale(1.05); }
.start-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #159a4c; }
.menu-btn { display: block; margin: 10px auto 0; background: #eee; border: 2px solid #ccc; border-radius: 30px;
  padding: 8px 26px; font-family: inherit; font-weight: bold; cursor: pointer; color: #666; }
.menu-btn:hover { background: #ddd; }
.controls-hint { margin-top: 12px; font-size: 0.85rem; color: #888; }
.controls-hint kbd { background: #15803d; color: #fff; border-radius: 6px; padding: 2px 8px; font-family: inherit; margin: 0 2px; box-shadow: 0 2px 0 #14532d; }
.final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.final-stat { background: linear-gradient(135deg,#f0fdf4,#dcfce7); border-radius: 16px; padding: 10px; border: 2px solid #bbf7d0; }
.final-value { display: block; font-family: 'Bubblegum Sans'; font-size: 1.8rem; color: #15803d; }
.final-label { font-size: 0.62rem; letter-spacing: 1px; color: #888; font-weight: bold; }
.rank { font-size: 1.25rem; font-weight: bold; background: linear-gradient(90deg,#ffd93d,#ff9a3d); display: inline-block;
  padding: 6px 22px; border-radius: 30px; margin: 6px 0; animation: bounce 1s infinite; border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25); }

.game-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.94); border-radius: 18px; padding: 8px 16px; border: 3px solid #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12); flex-wrap: wrap; }
.dpad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 46px); gap: 4px; }
.dpad-btn { border-radius: 12px; border: 3px solid #22cc66; background: linear-gradient(180deg,#fff,#d3f8df);
  font-size: 1.2rem; cursor: pointer; box-shadow: 0 3px 0 #15803d; color: #15803d; }
.dpad-btn:active { transform: translateY(2px); box-shadow: none; }
.power-ups { display: flex; gap: 8px; flex-wrap: wrap; }
.power-chip { background: linear-gradient(135deg,#ffd93d,#ff9a3d); border-radius: 20px; padding: 4px 12px;
  font-weight: bold; font-size: 0.85rem; border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  animation: overlayPop 0.3s; }
@media (max-width: 700px) {
  .game-title { font-size: 1.05rem; } .stats-bar { gap: 8px; } .stat-value { font-size: 1.05rem; }
  .overlay-content { padding: 18px; } .mode-selector { grid-template-columns: 1fr; }
  #snake-container { padding: 4px; } .target-letter { min-width: 44px; height: 44px; font-size: 1.6rem; }
}
/* fit-to-screen hardening: compact header, flexible stage, no clipping */
@media (max-width: 700px) {
  .game-header { padding: 6px 10px; gap: 6px; }
  .game-main { min-height: 420px; }
  .stat-label { display: none; }
  .stat-icon { font-size: 1.1rem; }
  .overlay-content h2 { font-size: 1.6rem; }
  .controls-hint { display: none; }
}
@media (max-height: 500px) {
  .game-main { min-height: 360px; }
}
