:root {
  --pixel: 'Press Start 2P', monospace;
  --fa: 'Vazirmatn', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  background: #1a1030;
  background-image:
    radial-gradient(circle at 15% 15%, #34215e 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, #4a1e52 0%, transparent 50%),
    radial-gradient(circle at 50% 100%, #1e2f6b 0%, transparent 60%),
    #0e0820;
  font-family: var(--fa);
  color: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
}

#game-wrap {
  position: relative;
  border: 4px solid #0a0518;
  border-radius: 14px;
  box-shadow:
    0 0 0 2px rgba(255,217,59,0.5),
    0 0 40px rgba(123,80,255,0.35),
    0 24px 70px rgba(0,0,0,0.75),
    inset 0 0 60px rgba(0,0,0,0.4);
  background: #000;
  overflow: hidden;
  line-height: 0;
}
#game-wrap::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none; z-index: 6;
  border-radius: 10px;
  box-shadow: inset 0 3px 20px rgba(255,255,255,0.08);
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-family: var(--pixel);
  font-size: 11px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), transparent);
}
#hud span {
  white-space: nowrap;
  background: rgba(10,5,24,0.4);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(3px);
}
#hud-level { color: #7ec8ff; }

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 20px;
  background: linear-gradient(160deg, rgba(12,8,30,0.94), rgba(30,14,50,0.94));
  backdrop-filter: blur(2px);
  line-height: 1.5;
}
.overlay.show { display: flex; animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.title {
  font-family: var(--fa);
  font-weight: 900;
  font-size: clamp(28px, 8vw, 52px);
  color: #ffd93b;
  text-shadow: 4px 4px 0 #e23b2e, 7px 7px 0 rgba(0,0,0,0.4);
  animation: bounce 1.6s ease-in-out infinite;
}
@keyframes bounce { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }

.subtitle {
  font-family: var(--pixel);
  font-size: 10px;
  color: #7ec8ff;
  letter-spacing: 1px;
}
.best {
  font-family: var(--pixel);
  font-size: 11px;
  color: #ffd93b;
}
.controls-hint {
  font-size: 14px;
  color: #d8c8ff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.controls-hint p:nth-child(2) { font-size: 11px; opacity: 0.7; font-family: monospace; }

.btn {
  font-family: var(--fa);
  font-weight: 700;
  font-size: 16px;
  color: #120a24;
  background: linear-gradient(180deg, #ffe066, #f5b820);
  border: none;
  border-bottom: 5px solid #a97806;
  border-radius: 12px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s;
  box-shadow: 0 6px 20px rgba(245,184,32,0.4);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; }

#leaderboard {
  margin-top: 6px;
  min-width: 220px;
  max-width: 300px;
}
#leaderboard h3 {
  font-family: var(--pixel);
  font-size: 10px;
  color: #7ec8ff;
  margin-bottom: 8px;
}
.lb-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #e8dcff;
}
.lb-row span:last-child { color: #ffd93b; font-weight: 700; }

#touch-controls {
  display: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 8;
  justify-content: space-between;
  padding: 12px 16px;
  pointer-events: none;
}
#touch-controls .dpad { display: flex; gap: 12px; pointer-events: auto; }
.tbtn {
  pointer-events: auto;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  background: rgba(20,10,40,0.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.tbtn:active { background: rgba(245,184,32,0.6); transform: scale(0.94); }
.tbtn.jump {
  width: 76px; height: 76px;
  background: rgba(226,59,46,0.5);
  border-color: rgba(255,220,100,0.6);
}

footer {
  font-family: monospace;
  font-size: 12px;
  z-index: 20;
}
footer a { color: #7ec8ff; text-decoration: none; opacity: 0.7; }
footer a:hover { opacity: 1; text-decoration: underline; }