/* ===========================================================
   GRID CHOMPER — neon dark-space arcade skin
   =========================================================== */

@font-face {
  font-family: 'ArcadeFallback';
  src: local('Consolas'), local('Menlo'), local('monospace');
}

:root{
  --bg:            #050510;
  --bg-2:          #0a0a1c;
  --filled:        #1E3A8A;
  --filled-glow:   #3b82f6;
  --trail:         #FDE047;
  --player:        #FFD400;
  --ghost-red:     #ff4d5e;
  --ghost-green:   #37f2a1;
  --ghost-orange:  #ff9f45;
  --ghost-blue:    #4dd0ff;
  --ghost-purple:  #b45dff;
  --ghost-scared:  #6b7bff;
  --accent:        #37f2ff;
  --danger:        #ff2d55;
  --gold:          #ffd76a;
  --text:          #eaf6ff;
  --text-dim:      #7c8aa8;
  --panel:         rgba(10, 14, 30, 0.72);
  --panel-border:  rgba(55, 242, 255, 0.25);
  --radius: 10px;
}

*{ box-sizing: border-box; }

html, body{
  margin:0; padding:0; height:100%;
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

body{
  font-family: 'Rajdhani', 'Segoe UI', 'ArcadeFallback', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 15% -10%, #0f1c3d55, transparent 60%),
    radial-gradient(900px 700px at 110% 10%, #2a0f4d4d, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* subtle starfield */
body::before{
  content:"";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #ffffff55 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 60%, #ffffff40 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, #ffffff55 50%, transparent 51%),
    radial-gradient(1px 1px at 60% 30%, #ffffff33 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 90%, #ffffff40 50%, transparent 51%),
    radial-gradient(1px 1px at 25% 55%, #ffffff33 50%, transparent 51%);
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: .6;
  pointer-events: none;
  z-index: 0;
}

#app{
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* ===================== HUD ===================== */
#hud{
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 4px;
  background: linear-gradient(180deg, rgba(6,8,20,.95), rgba(6,8,20,.65));
  backdrop-filter: blur(6px);
  z-index: 5;
  flex-shrink: 0;
}

.hud-block{ display:flex; flex-direction:column; gap:2px; min-width: 90px; }
.hud-left{ align-items:flex-start; }
.hud-center{ align-items:center; flex:1; max-width: 420px; margin: 0 auto; }

.hud-logo{
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--player);
  text-shadow: 0 0 10px rgba(255,212,0,.55), 0 0 22px rgba(255,212,0,.22);
  text-align: center;
  white-space: nowrap;
  margin-top: 4px;
}

#area-bar-row{
  background: linear-gradient(180deg, rgba(6,8,20,.65), rgba(6,8,20,.95));
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}
.area-row-inner{
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
  padding: 4px 16px 12px;
}
.area-row-inner .hud-label{ flex-shrink: 0; }
.hud-right{ align-items:flex-end; position: relative; }

.hud-label{
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 700;
}

.hud-value{
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(55,242,255,.55);
  line-height: 1.1;
}
.hud-value.small{ font-size: 13px; color: var(--text); text-shadow:none; min-width:38px; text-align:right;}

.lives{ display:flex; gap:3px; margin-top:2px; min-height: 14px; }
.life-icon{
  width: 13px; height: 13px;
  background: radial-gradient(circle at 35% 30%, #ff8a8a, var(--danger) 70%);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 0 6px rgba(255,45,85,.7);
}

.area-row{ display:flex; align-items:center; gap:8px; width:100%; }
.progress-track{
  position: relative;
  flex:1;
  height: 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill{
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--filled), var(--filled-glow));
  box-shadow: 0 0 8px rgba(59,130,246,.8);
  transition: width .35s ease;
}
.progress-target{
  position:absolute; top:-2px; bottom:-2px; width:2px;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}

.icon-btn{
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: 14px;
  cursor: pointer;
  opacity: .5;
  filter: grayscale(60%);
  transition: opacity .15s ease, filter .15s ease, box-shadow .15s ease, background .15s ease;
}
.icon-btn:active{ transform: scale(.9); }
.icon-btn.active{
  opacity: 1;
  filter: none;
  background: rgba(55,242,255,.12);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(55,242,255,.35);
}
.sound-btn-row{
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

#powerup-bar{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 8px 16px 6px;
  z-index: 6;
}
.powerup-chip{
  display:flex; align-items:center; gap:7px;
  padding: 5px 10px 5px 8px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  animation: chipIn .25s ease;
}
.powerup-chip .pu-icon{
  font-size: 14px;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(255,255,255,.35));
}
.powerup-chip .pu-track{
  position: relative;
  width: 54px;
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.powerup-chip .pu-fill{
  position: absolute;
  top:0; left:0; bottom:0;
  border-radius: 4px;
  box-shadow: 0 0 6px currentColor;
  transition: width .12s linear;
}
@keyframes chipIn{ from{ opacity:0; transform: translateY(-6px) scale(.8);} to{opacity:1; transform:none;} }

/* ===================== STAGE ===================== */
#stage{
  flex: 1;
  position: relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height: 0;
  padding: 3px;
}

#game-canvas{
  background: #000;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(55,242,255,.18),
    0 0 40px rgba(30,58,138,.35),
    0 20px 60px rgba(0,0,0,.6);
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

#fx-layer{
  position:absolute; inset:0;
  pointer-events:none;
  overflow:hidden;
}

/* screen shake */
.shake{ animation: shakeAnim .35s ease; }
@keyframes shakeAnim{
  0%,100%{ transform: translate(0,0); }
  20%{ transform: translate(-8px,4px); }
  40%{ transform: translate(7px,-5px); }
  60%{ transform: translate(-6px,-3px); }
  80%{ transform: translate(5px,4px); }
}

/* confetti */
.confetti-piece{
  position:absolute;
  top:-10px;
  width:8px; height:14px;
  opacity:.95;
  animation: confettiFall linear forwards;
  border-radius: 2px;
}
@keyframes confettiFall{
  to{ transform: translateY(120vh) rotate(540deg); opacity: .2; }
}

/* ===================== MOBILE CONTROLS ===================== */
#touch-controls{
  position: fixed;
  right: 14px;
  bottom: 54px;
  z-index: 8;
  display: none;
}
body.is-touch #touch-controls{ display:block; }

.dpad{
  position: relative;
  width: 148px;
  height: 148px;
}
.dpad-btn{
  position: absolute;
  width: 48px; height: 48px;
  background: rgba(20,26,50,.75);
  border: 1px solid var(--panel-border);
  color: var(--accent);
  font-size: 16px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}
.dpad-btn:active{ background: rgba(55,242,255,.3); }
.dpad-up{ top:0; left:50px; }
.dpad-down{ bottom:0; left:50px; }
.dpad-left{ top:50px; left:0; }
.dpad-right{ top:50px; right:0; }

/* ===================== OVERLAY ===================== */
.overlay{
  position: fixed; inset: 0;
  z-index: 20;
  display:flex;
  align-items:center;
  justify-content:center;
  background: radial-gradient(1200px 800px at 50% 30%, rgba(20,25,60,.55), rgba(2,3,10,.92));
  backdrop-filter: blur(3px);
  transition: opacity .25s ease;
}
.overlay.hidden{ display:none; }

.overlay-card{
  width: min(420px, 88vw);
  max-height: 84vh;
  overflow-y: auto;
  padding: 28px 24px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 60px rgba(55,242,255,.15), 0 30px 60px rgba(0,0,0,.5);
  text-align: center;
  animation: cardIn .35s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes cardIn{
  from{ opacity:0; transform: translateY(18px) scale(.94); }
  to{ opacity:1; transform:none; }
}

#overlay-title{
  font-family: 'Orbitron', sans-serif;
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: 3px;
  font-weight: 900;
  color: var(--player);
  text-shadow: 0 0 16px rgba(255,212,0,.6);
}
#overlay-sub{
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
#overlay-body{
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
  text-align: left;
}
#overlay-body p{ margin: 0 0 10px; }
#overlay-body .legend-row{
  display:flex; align-items:center; gap:10px; margin-bottom:8px; font-size:13px;
}
#overlay-body .swatch{ width:16px; height:16px; border-radius:4px; flex-shrink:0; }
#overlay-body .swatch.circle{ border-radius:50%; }

#overlay-actions{ display:flex; gap:10px; justify-content:center; flex-wrap: wrap; }

.btn{
  border:none;
  cursor:pointer;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 13px;
  padding: 12px 22px;
  border-radius: 10px;
  color: #001018;
  background: linear-gradient(180deg, var(--accent), #1aa8bf);
  box-shadow: 0 0 18px rgba(55,242,255,.5), inset 0 1px rgba(255,255,255,.5);
  transition: transform .12s ease;
}
.btn:active{ transform: scale(.94); }
.btn.secondary{
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  box-shadow:none;
}

.stat-final{ font-size: 15px; margin: 4px 0; color: var(--gold); font-weight:700; }

.feedback-block{
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
  text-align: center;
}
.feedback-title{
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  margin-bottom: 6px;
}
.feedback-block p{
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 6px;
}
.feedback-sub{ font-style: italic; }
.feedback-btn{
  display: inline-block;
  margin-top: 8px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
  text-decoration: none;
  border-radius: 20px;
  background: rgba(180,93,255,.12);
  border: 1px solid rgba(180,93,255,.4);
  transition: background .15s ease, transform .12s ease;
}
.feedback-btn:hover{ background: rgba(180,93,255,.22); }
.feedback-btn:active{ transform: scale(.95); }

@media (max-width: 640px){
  .hud-value{ font-size:18px; }
  .hud-block{ min-width:64px; }
  #overlay-title{ font-size:20px; }
  .hud-logo{ font-size: 15px; letter-spacing: 2px; }
  .icon-btn{ width: 26px; height: 26px; font-size: 12px; }
  .sound-btn-row{ gap: 4px; }
}

/* ===================== FOOTER ===================== */
#site-footer{
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(6,8,20,.9);
  border-top: 1px solid var(--panel-border);
  z-index: 5;
}
.footer-credit{
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: .3px;
}
.footer-credit span:first-child{ color: var(--text); font-weight: 600; }
.footer-copy{ font-size: 10px; }
.footer-social{ display: flex; gap: 10px; }
.footer-social a{
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 7px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--panel-border);
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.footer-social a:hover{ background: rgba(55,242,255,.15); color: var(--accent); transform: translateY(-1px); }
.footer-social a:active{ transform: scale(.9); }

@media (max-width: 640px){
  #site-footer{ padding: 6px 10px; }
  .footer-credit{ font-size: 9px; }
  .footer-copy{ font-size: 8px; }
  .footer-social a{ width: 22px; height: 22px; font-size: 12px; }
}

/* ===================== DIFFICULTY SELECTOR ===================== */
.diff-select{ margin-bottom: 16px; }
.diff-buttons{ display:flex; gap:10px; }
.diff-btn{
  flex: 1;
  padding: 10px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text-dim);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
}
.diff-btn:hover{ color: var(--text); }
.diff-btn.diff-medium.active{
  color: #001018;
  background: linear-gradient(180deg, #4dd0ff, #2b8fb0);
  border-color: #4dd0ff;
  box-shadow: 0 0 14px rgba(77,208,255,.5);
}
.diff-btn.diff-hard.active{
  color: #1a0000;
  background: linear-gradient(180deg, #ff6b6b, #c23a3a);
  border-color: #ff6b6b;
  box-shadow: 0 0 14px rgba(255,90,90,.5);
}

/* ===================== FEATURE-INTRO ICON BADGE ===================== */
.overlay-icon-badge{
  width: 68px; height: 68px;
  margin: 0 auto 14px;
  display:flex; align-items:center; justify-content:center;
  font-size: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.12), rgba(55,242,255,.06));
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 24px rgba(55,242,255,.35);
  animation: badgePop .35s cubic-bezier(.2,.9,.3,1.4);
}
.overlay-icon-badge-img{
  width: 78px; height: 78px;
  background: radial-gradient(circle at 35% 30%, rgba(180,93,255,.18), rgba(180,93,255,.05));
  border-color: rgba(180,93,255,.35);
  box-shadow: 0 0 26px rgba(180,93,255,.45);
  overflow: hidden;
}
.overlay-icon-badge-img img{
  width: 72%;
  height: 72%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(180,93,255,.6));
}
@keyframes badgePop{
  from{ opacity:0; transform: scale(.5); }
  to{ opacity:1; transform: scale(1); }
}

/* power-up nearing expiry */
.powerup-chip.low{ animation: puPulse .6s ease-in-out infinite; }
@keyframes puPulse{
  0%,100%{ opacity:1; }
  50%{ opacity:.55; }
}

/* ===================== INTRO SPLASH (shown once per page load) ===================== */
#intro-splash{
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: splashBgFade 3.1s ease forwards;
}
#intro-splash h1{
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--player, #FFD400);
  text-shadow: 0 0 24px rgba(255,212,0,.55);
  opacity: 0;
  animation: splashTitleFade 3.1s ease forwards;
}
#intro-splash p{
  margin: 0;
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--text-dim, #7c8aa8);
  opacity: 0;
  animation: splashSubFade 3.1s ease forwards;
}
@keyframes splashBgFade{
  0%{ opacity: 1; }
  88%{ opacity: 1; }
  100%{ opacity: 0; }
}
@keyframes splashTitleFade{
  0%{ opacity: 0; transform: scale(1.4); }
  22%{ opacity: 1; transform: scale(1); }
  82%{ opacity: 1; transform: scale(1); }
  100%{ opacity: 0; transform: scale(1.02); }
}
@keyframes splashSubFade{
  0%{ opacity: 0; transform: translateY(6px); }
  30%{ opacity: 0; transform: translateY(6px); }
  45%{ opacity: 1; transform: translateY(0); }
  82%{ opacity: 1; }
  100%{ opacity: 0; }
}
