@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Press+Start+2P&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  user-select: none;
}

/* Loading screen */
#loadingScreen {
  position: fixed; inset: 0; z-index: 200;
  background: #0a0a0a;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.6s ease;
}
#loadingScreen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-donut {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: conic-gradient(#FF69B4 0%, #D4863A 30%, #FFD700 60%, #FF69B4 100%);
  animation: spin 1s linear infinite;
  position: relative;
}
.loading-donut::after {
  content: '';
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: #0a0a0a;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  margin-top: 24px;
  color: #FF69B4;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  animation: blink 1s steps(2) infinite;
}
.loading-bar {
  width: 200px; height: 6px;
  background: #222;
  border-radius: 3px;
  margin-top: 16px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #FF69B4, #FFD700);
  border-radius: 3px;
  transition: width 0.3s ease;
}
@keyframes blink { 50% { opacity: 0; } }

/* Pause overlay */
#pauseOverlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.85);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#pauseOverlay.active {
  display: flex;
}
.pause-title {
  font-family: 'Bangers', cursive;
  font-size: 48px;
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  margin-bottom: 20px;
}
.pause-info {
  color: #aaa;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  line-height: 2;
  text-align: center;
}
.pause-info span {
  color: #FF69B4;
}

/* Game wrapper */
#gameWrapper {
  position: relative;
  border: 4px solid #ff6b35;
  border-radius: 8px;
  box-shadow:
    0 0 40px rgba(255,107,53,0.4),
    inset 0 0 20px rgba(0,0,0,0.5),
    0 0 80px rgba(255,107,53,0.15);
}

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

/* Scoreboard overlay */
#scoreboardOverlay {
  position: fixed; inset: 0; z-index: 160;
  background: rgba(0,0,0,0.9);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#scoreboardOverlay.active { display: flex; }
.scoreboard-title {
  font-family: 'Bangers', cursive;
  font-size: 36px;
  color: #FFD700;
  margin-bottom: 16px;
}
.scoreboard-list {
  list-style: none; padding: 0;
  width: 300px;
}
.scoreboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #ccc;
  border-bottom: 1px solid #333;
}
.scoreboard-list li:first-child { color: #FFD700; }
.scoreboard-list li:nth-child(2) { color: #C0C0C0; }
.scoreboard-list li:nth-child(3) { color: #CD7F32; }
.scoreboard-list li .rank { color: #FF69B4; width: 30px; }
.scoreboard-close {
  margin-top: 20px;
  color: #888;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
}

/* Mobile controls */
#mobileControls {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 180px;
  z-index: 100;
}

.ctrl-btn {
  position: absolute;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  background: rgba(255,107,53,0.4);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  backdrop-filter: blur(4px);
  transition: background 0.1s;
}
.ctrl-btn:active { background: rgba(255,107,53,0.8); }

#btn-left  { left: 20px; bottom: 60px; }
#btn-right { left: 96px; bottom: 60px; }
#btn-up    { left: 58px; bottom: 120px; }
#btn-down  { left: 58px; bottom: 4px; }
#btn-knife { right: 90px; bottom: 60px; width: 64px; height: 64px; background: rgba(255,50,50,0.5); font-size: 8px; }
#btn-punch { right: 16px; bottom: 60px; width: 64px; height: 64px; background: rgba(50,100,255,0.5); font-size: 8px; }
#btn-jump  { right: 50px; bottom: 130px; width: 64px; height: 64px; background: rgba(50,255,50,0.4); font-size: 8px; }
#btn-pause { position: fixed; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 8px; font-size: 12px; background: rgba(0,0,0,0.5); z-index: 110; }

@media (max-width: 900px) {
  #mobileControls { display: block; }
  #btn-pause { display: flex; }
  body { justify-content: flex-start; padding-top: 10px; }
}

@media (min-width: 901px) {
  #btn-pause { display: none; }
}
