/* ===================================================
   NEON SNAKE — style.css
   Cyberpunk / neon arcade aesthetic
=================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Share+Tech+Mono&family=Rajdhani:wght@400;600;700&display=swap');

/* ─── CSS Variables ─── */
:root {
  --cyan:       #00F0FF;
  --cyan-dark:  #00B8CC;
  --cyan-dim:   #004A55;
  --electric:   #7DF9FF;
  --pink:       #FF2D78;
  --yellow:     #FFE000;
  --black:      #040608;
  --bg:         #060A0F;
  --bg2:        #0A1018;
  --bg3:        #0F1620;
  --bg4:        #141E2A;
  --border:     rgba(0,240,255,.15);
  --text:       #C8F0FF;
  --text-dim:   #5A8A9A;
  --font-px:    'Press Start 2P', monospace;
  --font-mono:  'Share Tech Mono', monospace;
  --font-body:  'Rajdhani', sans-serif;
  --glow:       0 0 20px rgba(0,240,255,.6), 0 0 40px rgba(0,240,255,.2);
  --glow-sm:    0 0 10px rgba(0,240,255,.4);
  --glow-pink:  0 0 20px rgba(255,45,120,.6);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--black);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

/* ─── Scanline Overlay ─── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0,0,0,.06) 3px, rgba(0,0,0,.06) 4px
  );
  animation: scanMove 8s linear infinite;
}
@keyframes scanMove {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

/* ─── Pixel Grid BG ─── */
.grid-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,240,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,240,255,.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ===================================================
   NAVBAR
=================================================== */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 36px;
  background: rgba(4,6,8,.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: var(--font-px);
  font-size: 12px;
  color: var(--cyan);
  text-shadow: var(--glow);
  letter-spacing: 1px;
}
.nav-logo em { color: var(--pink); font-style: normal; }

.nav-links { display: flex; gap: 32px; align-items: center; }
.nav-links a {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: color .2s;
}
.nav-links a:hover { color: var(--cyan); }

.nav-play-btn {
  font-family: var(--font-px);
  font-size: 9px;
  background: var(--cyan);
  color: var(--black);
  padding: 9px 20px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
  animation: btnPulse 2.5s ease-in-out infinite;
}
.nav-play-btn:hover {
  background: var(--electric);
  box-shadow: var(--glow);
}
@keyframes btnPulse {
  0%,100% { box-shadow: 0 0 8px rgba(0,240,255,.4); }
  50%      { box-shadow: 0 0 22px rgba(0,240,255,.8), 0 0 44px rgba(0,240,255,.3); }
}

.hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--cyan); border-radius: 2px; }

/* ===================================================
   HERO
=================================================== */
#hero {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 100px 24px 60px;
  overflow: hidden;
}

.hero-eyebrow {
  position: relative; z-index: 2;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 20px;
  opacity: .8;
}
.hero-eyebrow::before, .hero-eyebrow::after {
  content: '─────';
  color: var(--cyan-dim);
  margin: 0 10px;
}

.hero-title {
  position: relative; z-index: 2;
  font-family: var(--font-px);
  font-size: clamp(22px, 5vw, 48px);
  color: #fff;
  line-height: 1.4;
  margin-bottom: 12px;
  text-shadow: var(--glow);
}
.hero-title .line-cyan  { color: var(--cyan); display: block; }
.hero-title .line-white { color: #fff; display: block; }
.hero-title .line-pink  { color: var(--pink); display: block; text-shadow: var(--glow-pink); }

.hero-sub {
  position: relative; z-index: 2;
  font-family: var(--font-mono);
  font-size: clamp(14px, 2vw, 18px);
  color: var(--text-dim);
  max-width: 540px;
  margin: 0 auto 40px;
  letter-spacing: 1px;
}

.hero-cta-group {
  position: relative; z-index: 2;
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 56px;
}
.btn-play {
  font-family: var(--font-px);
  font-size: 11px;
  background: var(--cyan);
  color: var(--black);
  padding: 16px 36px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
  animation: btnPulse 2.5s ease-in-out infinite;
}
.btn-play:hover { background: var(--electric); transform: translateY(-2px); box-shadow: var(--glow); }

.btn-leaderboard {
  font-family: var(--font-px);
  font-size: 11px;
  background: transparent;
  color: var(--cyan);
  padding: 15px 36px;
  border-radius: 3px;
  border: 2px solid var(--cyan-dim);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
}
.btn-leaderboard:hover {
  border-color: var(--cyan);
  background: rgba(0,240,255,.07);
  transform: translateY(-2px);
}

/* ─── Game Container in Hero ─── */
.game-area-hero {
  position: relative; z-index: 2;
  width: 100%; max-width: 560px;
  margin: 0 auto;
}
.game-frame {
  border: 2px solid var(--cyan-dim);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,240,255,.1), inset 0 0 40px rgba(0,0,0,.5);
  position: relative;
}
.game-frame::before {
  content: '● NEON SNAKE v1.0';
  display: block;
  background: var(--bg2);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  letter-spacing: 2px;
}
#gameCanvas {
  display: block;
  width: 100%;
  cursor: pointer;
}

/* ─── In-game Score HUD ─── */
#scoreHud {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  font-family: var(--font-px);
  font-size: 9px;
}
#hudScore { color: var(--cyan); }
#hudHigh  { color: var(--yellow); }

/* ─── Overlays ─── */
.canvas-overlay {
  position: absolute;
  inset: 38px 0 0; /* below title bar */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(4,6,8,.88);
  backdrop-filter: blur(4px);
  z-index: 10;
  transition: opacity .3s;
}
.canvas-overlay.hidden { display: none; }

.overlay-icon { font-size: 42px; margin-bottom: 14px; }
.overlay-title {
  font-family: var(--font-px);
  font-size: clamp(14px, 3vw, 20px);
  color: var(--cyan);
  text-shadow: var(--glow);
  margin-bottom: 10px;
  text-align: center;
}
.overlay-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
  letter-spacing: 1px;
  text-align: center;
}
.overlay-score-display {
  font-family: var(--font-px);
  font-size: 22px;
  color: var(--yellow);
  margin-bottom: 24px;
}

.name-input-group {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; margin-bottom: 18px;
}
#playerNameInput {
  background: var(--bg3);
  border: 2px solid var(--cyan-dim);
  border-radius: 3px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--cyan);
  outline: none;
  transition: border-color .2s;
  width: 200px;
  text-align: center;
}
#playerNameInput:focus { border-color: var(--cyan); }
#playerNameInput::placeholder { color: var(--text-dim); opacity: .6; }

.btn-save-score {
  font-family: var(--font-px);
  font-size: 9px;
  background: var(--yellow);
  color: var(--black);
  border: none;
  border-radius: 3px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
}
.btn-save-score:hover { background: #ffcc00; box-shadow: 0 0 16px rgba(255,224,0,.5); }

.overlay-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.btn-restart {
  font-family: var(--font-px);
  font-size: 9px;
  background: var(--cyan);
  color: var(--black);
  border: none;
  border-radius: 3px;
  padding: 12px 24px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
}
.btn-restart:hover { background: var(--electric); box-shadow: var(--glow); }

.btn-outline {
  font-family: var(--font-px);
  font-size: 9px;
  background: transparent;
  color: var(--cyan);
  border: 2px solid var(--cyan-dim);
  border-radius: 3px;
  padding: 11px 24px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
}
.btn-outline:hover { border-color: var(--cyan); background: rgba(0,240,255,.07); }

/* ─── Touch controls ─── */
#touchControls {
  display: none;
  margin-top: 14px;
}
#touchControls.visible { display: grid; }
.touch-grid {
  display: grid;
  grid-template-areas: '. up .' 'left . right' '. down .';
  grid-template-columns: 60px 60px 60px;
  gap: 4px;
  justify-content: center;
}
.touch-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn:active { background: var(--bg4); border-color: var(--cyan); }
.touch-up    { grid-area: up; }
.touch-left  { grid-area: left; }
.touch-right { grid-area: right; }
.touch-down  { grid-area: down; }

/* ===================================================
   STATS STRIP
=================================================== */
#stats {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 32px 24px;
}
.stats-row {
  max-width: 900px; margin: 0 auto;
  display: flex; gap: 0; justify-content: space-around; flex-wrap: wrap;
}
.stat-item {
  text-align: center;
  padding: 0 24px;
  border-right: 1px solid var(--border);
  flex: 1; min-width: 120px;
}
.stat-item:last-child { border-right: none; }
.stat-num {
  font-family: var(--font-px);
  font-size: clamp(18px, 4vw, 28px);
  color: var(--cyan);
  text-shadow: var(--glow-sm);
  display: block;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
  display: block;
}

/* ===================================================
   LEADERBOARD SECTION
=================================================== */
#leaderboard {
  position: relative;
  padding: 90px 24px;
  background: var(--bg);
}
.lb-container {
  max-width: 720px; margin: 0 auto; position: relative; z-index: 2;
}
.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--pink);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: block;
}
.section-title {
  font-family: var(--font-px);
  font-size: clamp(16px, 3vw, 24px);
  color: #fff;
  text-shadow: var(--glow);
  margin-bottom: 8px;
  line-height: 1.5;
}
.section-divider {
  width: 50px; height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  margin-bottom: 36px;
}

/* Leaderboard Table */
.lb-header {
  display: grid;
  grid-template-columns: 48px 1fr 120px;
  gap: 12px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.lb-list { list-style: none; }
.lb-row {
  display: grid;
  grid-template-columns: 48px 1fr 120px;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0,240,255,.05);
  align-items: center;
  transition: background .2s;
  border-radius: 4px;
}
.lb-row:hover { background: var(--bg2); }
.lb-row.rank-1 { border-left: 3px solid var(--yellow); background: rgba(255,224,0,.03); }
.lb-row.rank-2 { border-left: 3px solid #C0C0C0; background: rgba(192,192,192,.03); }
.lb-row.rank-3 { border-left: 3px solid #CD7F32; background: rgba(205,127,50,.03); }

.lb-rank {
  font-family: var(--font-px);
  font-size: 11px;
  color: var(--text-dim);
}
.lb-row.rank-1 .lb-rank { color: var(--yellow); text-shadow: 0 0 8px rgba(255,224,0,.5); }
.lb-row.rank-2 .lb-rank { color: #C0C0C0; }
.lb-row.rank-3 .lb-rank { color: #CD7F32; }

.lb-name {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  letter-spacing: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-score {
  font-family: var(--font-px);
  font-size: 13px;
  color: var(--cyan);
  text-shadow: var(--glow-sm);
  text-align: right;
}
.lb-empty {
  text-align: center;
  padding: 40px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 1px;
}

.lb-clear-btn {
  margin-top: 24px;
  background: transparent;
  border: 1px solid rgba(255,45,120,.3);
  color: rgba(255,45,120,.6);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .2s;
}
.lb-clear-btn:hover { border-color: var(--pink); color: var(--pink); }

/* ===================================================
   HOW TO PLAY
=================================================== */
#howtoplay {
  background: var(--bg2);
  padding: 90px 24px;
  position: relative;
}
.htp-container {
  max-width: 960px; margin: 0 auto;
}
.htp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 48px;
}
.htp-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px 22px;
  transition: transform .2s, box-shadow .2s;
}
.htp-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,240,255,.08);
}
.htp-icon { font-size: 32px; margin-bottom: 14px; display: block; }
.htp-card h3 {
  font-family: var(--font-px);
  font-size: 9px;
  color: var(--cyan);
  margin-bottom: 10px;
  line-height: 1.7;
}
.htp-card p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}
.kbd {
  display: inline-block;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  margin: 1px;
}

/* ===================================================
   FOOTER
=================================================== */
footer {
  background: var(--black);
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
}
.footer-logo {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--cyan);
  text-shadow: var(--glow-sm);
  margin-bottom: 12px;
}
.footer-logo em { color: var(--pink); font-style: normal; }
footer p {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  opacity: .6;
  letter-spacing: 1px;
}

/* ===================================================
   SCROLL REVEAL
=================================================== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===================================================
   RESPONSIVE
=================================================== */
@media (max-width: 768px) {
  #navbar { padding: 14px 20px; }
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .nav-links.open {
    display: flex; flex-direction: column;
    position: fixed; top: 55px; left: 0; right: 0;
    background: rgba(4,6,8,.97);
    padding: 24px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
  }
  #hero { padding: 90px 16px 40px; }
  .hero-eyebrow::before, .hero-eyebrow::after { display: none; }
  #touchControls.visible { display: grid; }
  .stat-item { min-width: 80px; padding: 0 12px; }
}

@media (max-width: 480px) {
  .stats-row { gap: 0; }
  .stat-item { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 0; }
  .stat-item:last-child { border-bottom: none; }
}

.gold {
  background: linear-gradient(90deg, rgba(255,215,0,0.15), transparent);
  border-left: 4px solid gold;
}

.silver {
  background: linear-gradient(90deg, rgba(192,192,192,0.15), transparent);
  border-left: 4px solid silver;
}

.bronze {
  background: linear-gradient(90deg, rgba(205,127,50,0.15), transparent);
  border-left: 4px solid #cd7f32;
}