*{margin:0;padding:0;box-sizing:border-box;}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}
body{
  font-family:avenir,sans-serif;
  color:#fff;
  display:flex;
  flex-direction:column;
  min-height:100vh;
  background:linear-gradient(160deg,#000 0%,#0b1220 30%,#0a2a3f 70%,#1DA3CC 130%);
  background-size:400% 400%;
  animation:gradientShift 25s ease infinite;
  overflow-x:hidden;
}
@keyframes gradientShift{
  0%{background-position:0% 50%;}
  50%{background-position:100% 50%;}
  100%{background-position:0% 50%;}
}
/* 100svh = "small viewport height" (dynamic & notch-safe) */
@supports not (height: 100svh) {
  .artboard {
    height: calc(100vh - 60px);
  }
}

footer {
  width: 100%;
  background: #000;
  text-align: center;
  padding: 10px 0;
  font-size: 14px;
  color: #FFFFFF;
  margin-top: auto;
  position: relative;
  bottom: 0;
  left: 0;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.4);
  z-index: 5;
}
footer span.beat {
  color: red;
  animation: beat 0.3s infinite alternate;
}
@keyframes beat { to { transform: scale(1.4); } }
@keyframes gradientShift{0%{background-position:0% 50%;}50%{background-position:100% 50%;}100%{background-position:0% 50%;}}

header{text-align:center;margin-top:25px;}
header img{height:160px;width:auto;filter:drop-shadow(0 0 10px #1DA3CC);}
#playButton{
  background:rgba(29,163,204,0.15);
  border:1px solid #1DA3CC;
  color:#1DA3CC;
  font-size:18px;
  padding:10px 25px;
  border-radius:8px;
  cursor:pointer;
  margin:25px auto;
  display:block;
  text-shadow:0 0 8px #1DA3CC;
  transition:all .3s ease;
  animation:pulse 3s ease-in-out infinite;
}
#playButton:hover{background:#1DA3CC;color:#000;box-shadow:0 0 20px #1DA3CC;}
@keyframes pulse{0%,100%{box-shadow:0 0 8px #1DA3CC;}50%{box-shadow:0 0 20px #1DA3CC;}}

/* ===== SIDEBAR MENU ===== */
#menuToggle {
  position: fixed;
  top: 25px;
  right: 25px;
  width: 40px;
  height: 30px;
  cursor: pointer;
  z-index: 3000; /* ⬅ Raise above sidebar (which is 2000) */
}
#menuToggle span{
  display:block;
  width:100%;height:4px;
  margin-bottom:6px;
  background:#1DA3CC;
  border-radius:2px;
  transition:all .3s ease;
}
#menuToggle.active span:nth-child(1){transform:translateY(10px) rotate(45deg);}
#menuToggle.active span:nth-child(2){opacity:0;}
#menuToggle.active span:nth-child(3){transform:translateY(-10px) rotate(-45deg);}

.sidebar {
  position: fixed;
  top: 0;
  right: -280px;
  height: 100vh;
  width: 260px;
  background: rgba(10,15,25,0.95);
  box-shadow: -2px 0 20px rgba(29,163,204,0.4);
  backdrop-filter: blur(6px);
  padding-top: 90px;
  transition: right .4s ease;
  z-index: 2000; /* ⬅ Raise above game HUD */
}
.sidebar.active {
  right: 0;
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.8);
}
.sidebar a{
  display:block;
  color:#1DA3CC;
  text-decoration:none;
  padding:12px 25px;
  font-size:18px;
  border-bottom:1px solid rgba(29,163,204,0.1);
  transition:all .3s;
}
.sidebar a:hover{
  background:rgba(29,163,204,0.2);
  box-shadow:inset 0 0 10px #1DA3CC;
  color:#fff;
}

/* --- ARTBOARD --- */
.artboard {
  position: relative;
  width: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 4px solid #1DA3CC;
  border-radius: 12px;
  box-shadow: 0 0 25px rgba(29,163,204,.6);
  background: radial-gradient(circle at center, #000 40%, #0a1a25 100%);
  overflow: hidden;

  /* Fills between header and footer */
  height: calc(100svh - (var(--header-height, 180px) + var(--footer-height, 60px)));
  margin: 10px auto;
}

/* Fallback for older browsers */
@supports not (height: 100svh) {
  .artboard {
    height: calc(100vh - 240px);
  }
}
@media (orientation: landscape) {
  .artboard {
    aspect-ratio: auto; /* override ratio limit */
    height: 100vh;      /* ensure full vertical fit */
  }
}
canvas{width:100%;height:100%;display:block;image-rendering:pixelated;border-radius:8px;touch-action:none;}

/* --- HUD --- */
#hud{position:relative;z-index:1;top:10px;left:10px;display:flex;gap:20px;font-size:14px;color:#1DA3CC;text-shadow:0 0 10px #1DA3CC;}
.healthbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 180px;
}
.healthcell{width:16px;height:16px;border:1px solid #1DA3CC;border-radius:3px;background:#0b1a24;box-shadow:0 0 10px #1DA3CC inset;}
.healthcell.lost{background:#2a0000;border-color:red;box-shadow:0 0 10px red inset;}
#minimap{position:absolute;bottom:10px;right:10px;width:140px;height:100px;border:1px solid #1DA3CC;border-radius:4px;background:rgba(10,20,30,0.6);}
#gameOver{position:absolute;inset:0;background:rgba(0,0,0,0.9);display:none;align-items:center;justify-content:center;flex-direction:column;color:#FF3B3B;text-align:center;font-size:22px;text-shadow:0 0 40px #FF0000;}
#restartBtn{margin-top:20px;background:#e3b324;color:#000;border:none;padding:10px 20px;border-radius:6px;cursor:pointer;font-weight:bold;box-shadow:0 0 15px #e3b324;}

/* === SAFARI LANDSCAPE HEIGHT FIX === */
html, body {
  height: 100%;
  min-height: -webkit-fill-available;
}

.artboard {
  height: 100vh; /* fallback for non-iOS */
  min-height: -webkit-fill-available; /* iOS actual full height */
  max-height: 100vh;
  display: none;
}
/* === HUD LAYOUT UPDATE === */
#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 14px;
  color: #1DA3CC;
  text-shadow: 0 0 10px #1DA3CC;
  z-index: 100;
}

/* Left cluster (health, enemies, diamonds) */
#hud-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Right cluster (score, level) */
#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.hud-stat span:first-child {
  font-weight: bold;
  margin-right: 4px;
}

/* Icon blocks (Bad Bits / Good Bits) */
.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

#enemyIcon, #diamondIcon {
  image-rendering: pixelated;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(29,163,204,0.3);
  border-radius: 4px;
  background: rgba(10,20,30,0.6);
}
#gunMeter {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 14px;
  color: #00ffff;
  font-family: monospace;
}
#gunLevelContainer {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  color: #1DA3CC;
  text-shadow: 0 0 8px #1DA3CC;
  font-size: 14px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(29,163,204,0.3);
}

#gunBar {
  width: 120px;
  height: 8px;
  border: 1px solid #1DA3CC;
  border-radius: 4px;
  background: rgba(10,20,30,0.6);
  overflow: hidden;
  box-shadow: inset 0 0 10px #1DA3CC;
}

#gunFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ffff, #1DA3CC);
  transition: width 0.3s ease, background 0.3s ease;
}
header, footer, .artboard {
  transition: all 0.4s ease;
}