:root {
  --bg-1: #070a14;
  --bg-2: #0c1024;
  --neon-cyan: #31e0ff;
  --neon-cyan-dark: #0e8fb3;
  --neon-green: #3dffa0;
  --neon-green-dark: #12a866;
  --neon-purple: #b06bff;
  --neon-purple-dark: #6c2fc9;
  --neon-yellow: #ffd23d;
  --neon-pink: #ff4d8d;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text-hi: #eaf6ff;
  --text-lo: #8ea3c2;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-image: url("bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow: hidden;
  font-family: Rajdhani, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#gameWrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(49, 224, 255, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.18), inset 0 0 0 2px rgba(255, 255, 255, 0.12), 0 0 18px rgba(49, 224, 255, 0.25);
}

.num {
  font-family: 'Orbitron', sans-serif;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 0 14px;
  pointer-events: none;
  z-index: 10;
}

.hud-block {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 8px 14px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  min-width: 74px;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-lo);
  text-transform: uppercase;
}

.hud-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-hi);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.25);
}

.hud-value.best {
  color: var(--neon-yellow);
  text-shadow: 0 0 12px rgba(255, 210, 61, 0.6);
}

/* .hud-coins {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--neon-yellow);
  margin-top: 2px;
} */

#lengthWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#lengthVal {
  font-size: 32px;
  color: var(--neon-green);
  text-shadow: 0 0 14px rgba(61, 255, 160, 0.65);
}

#chancesTag {
  margin-top: 6px;
  font-size: 14px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pauseBtn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

#pauseBtn svg {
  width: 16px;
  height: 16px;
  fill: var(--text-hi);
}

#shieldBar {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 10;
  background: rgba(176, 107, 255, 0.16);
  border: 1px solid rgba(176, 107, 255, 0.5);
  padding: 5px 12px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
}

#shieldBar.show {
  display: flex;
}

#shieldBar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-purple);
  box-shadow: 0 0 8px var(--neon-purple);
  animation: pulse 0.6s infinite alternate;
}

#shieldBar span {
  font-size: 12px;
  font-weight: 600;
  color: #e3cfff;
}

@keyframes pulse {
  from {
    opacity: 0.4;
  }

  to {
    opacity: 1;
  }
}

#topFade {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 150px;
  background: linear-gradient(to bottom, rgba(5, 7, 16, 0.96) 0%, rgba(5, 7, 16, 0.82) 40%, rgba(5, 7, 16, 0) 100%);
  z-index: 6;
  pointer-events: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(160deg, rgba(22, 28, 54, 0.92), rgba(10, 13, 28, 0.94));
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  padding: 20px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  transform: translateY(14px) scale(0.97);
  transition: transform .3s cubic-bezier(.2, .9, .25, 1.2);
  max-height: 88vh;
  overflow-y: auto;
}

.overlay.show .panel {
  transform: translateY(0) scale(1);
}

.logo-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 34px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green) 55%, var(--neon-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(61, 224, 255, 0.25);
  margin: 0 0 4px;
}

.logo-sub {
  color: var(--text-lo);
  font-size: 13px;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
}

.htp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.htp-icon {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-family: 'Orbitron';
  font-weight: 700;
}

.htp-text b {
  display: block;
  font-size: 13.5px;
  color: var(--text-hi);
}

.htp-text small {
  color: var(--text-lo);
  font-size: 11.5px;
  line-height: 1.3;
}

.icon-drag {
  background: linear-gradient(145deg, #1c2b45, #10192e);
  color: var(--neon-cyan);
}

.icon-orb {
  background: radial-gradient(circle at 35% 30%, #fff2b0, var(--neon-yellow));
  color: #3a2a00;
}

.icon-block {
  background: linear-gradient(160deg, var(--neon-cyan), var(--neon-cyan-dark));
  color: #03222c;
}

.icon-star {
  background: radial-gradient(circle at 35% 30%, #eadcff, var(--neon-purple));
  color: #2a0d55;
}

.icon-heart {
  background: radial-gradient(circle at 35% 30%, #ffd1de, var(--neon-pink));
  color: #4a0018;
}

.btn {
  font-family: 'Outfit';
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.4px;
  border: none;
  border-radius: 30px;
  padding: 14px 20px;
  width: 100%;
  cursor: pointer;
  color: #04121a;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-green));
  box-shadow: 0 8px 22px rgba(49, 224, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  margin-top: 6px;
  transition: transform .12s ease, box-shadow .12s ease;

  /* 3D Border + Depth */
  box-shadow:
    /* Outer depth */
    0 12px 24px rgba(0, 0, 0, 0.35),
    0 8px 20px rgba(49, 224, 255, 0.25),

    /* Top highlight */
    inset 0 2px 0 rgba(255, 255, 255, 0.55),

    /* Bottom shadow */
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),

    /* Inner border */
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),

    /* Neon glow */
    0 0 18px rgba(49, 224, 255, 0.25);

  margin-top: 6px;
  transition: all .2s ease;


}

.btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(49, 224, 255, 0.22);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-hi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
}

.stat-grid {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 18px;
}

.stat-chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 10px 6px;
}

.stat-chip .v {
  font-family: 'Orbitron';
  font-size: 20px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(49, 224, 255, 0.5);
}

.stat-chip.gold .v {
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(255, 210, 61, 0.5);
}

.stat-chip .l {
  font-size: 10px;
  color: var(--text-lo);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 3px;
}

.mute-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}

.mute-toggle svg {
  width: 16px;
  height: 16px;
  fill: var(--text-hi);
}

#newbest {
  display: none;
  font-size: 12px;
  color: var(--neon-yellow);
  background: rgba(255, 210, 61, 0.12);
  border: 1px solid rgba(255, 210, 61, 0.4);
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

#newbest.show {
  display: inline-block;
}

/* preloader */
#preloader {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity .5s ease;
}

.pl-worm {
  display: flex;
  gap: 6px;
  margin-bottom: 26px;
}

.pl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #baffe0, var(--neon-green));
  box-shadow: 0 0 12px rgba(61, 255, 160, 0.7);
  animation: plbounce 1s ease-in-out infinite;
}

.pl-dot:nth-child(1) {
  animation-delay: 0s;
}

.pl-dot:nth-child(2) {
  animation-delay: 0.1s;
}

.pl-dot:nth-child(3) {
  animation-delay: 0.2s;
}

.pl-dot:nth-child(4) {
  animation-delay: 0.3s;
}

.pl-dot:nth-child(5) {
  animation-delay: 0.4s;
}

@keyframes plbounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-14px);
  }
}

.pl-title {
  font-family: 'Orbitron';
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 18px;
}

.pl-bar {
  width: 200px;
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pl-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
  box-shadow: 0 0 10px rgba(61, 255, 160, 0.6);
  transition: width .15s ease;
}

.pl-pct {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-lo);
  letter-spacing: 1px;
}