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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0018;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Courier New', monospace;
}

#gameContainer { position: relative; overflow: hidden; touch-action: none; }

canvas { display: block; touch-action: none; }

#ui { position: absolute; top:0; left:0; right:0; bottom:0; pointer-events: none; }

#score {
  position: absolute; top: 5%; left: 50%;
  transform: translateX(-50%);
  color: #fff; font-size: 14vw; font-weight: bold;
  text-shadow: 0 0 10px #ff00ff, 2px 2px 0 #000;
  letter-spacing: 4px;
  z-index: 5;
  line-height: 1;
}

#overlay {
  position: absolute; top:0; left:0; right:0; bottom:0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(5,0,20,0.92);
  pointer-events: all;
  cursor: pointer;
  gap: 6px;
  touch-action: none;
  overflow-y: auto;
  padding: 20px 0 30px;
  z-index: 10;
}

#overlay h1 {
  color: #ff00ff; font-size: 11vw;
  text-shadow: 0 0 10px #ff00ff, 0 0 30px #ff00ff;
  letter-spacing: 3px;
  animation: pulse 1.4s ease-in-out infinite;
  text-align: center; padding: 0 10px;
}

#finalScore {
  color: #ffff00; font-size: 7vw;
  text-shadow: 0 0 10px #ffff00;
  letter-spacing: 2px; text-align: center;
}

#bestScore {
  color: #ff8800; font-size: 4.5vw;
  text-shadow: 0 0 8px #ff8800;
  margin-bottom: 4px; text-align: center;
}

.instructions {
  color: #fff; font-size: 4.5vw;
  text-shadow: 0 0 8px #00ffff;
  animation: blink 1.1s step-start infinite;
  text-align: center; margin-top: 10px;
  pointer-events: all;
}

#rankingBox { width: 88%; margin-top: 14px; pointer-events: none; }

.loadingRank { color: #aa88cc; font-size: 3.5vw; text-align: center; padding: 8px 0; }

.rankTable { width: 100%; border-collapse: collapse; font-size: 3.8vw; color: #fff; }
.rankTable th { color: #ff00ff; text-shadow: 0 0 6px #ff00ff; padding: 6px 4px; border-bottom: 1px solid #ff00ff44; letter-spacing: 1px; }
.rankTable td { padding: 5px 4px; text-align: center; border-bottom: 1px solid #ffffff11; }
.rankTable tr:first-child td { color: #ffd700; }
.rankTable tr:nth-child(2) td { color: #c0c0c0; }
.rankTable tr:nth-child(3) td { color: #cd7f32; }

@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.85;transform:scale(1.04)} }
@keyframes blink  { 0%,100%{opacity:1} 50%{opacity:.2} }

/* Countdown */
#countdownNum {
  color: #ff00ff;
  font-size: 40vw;
  font-weight: bold;
  text-shadow:
    0 0 20px #ff00ff,
    0 0 60px #ff00ff,
    0 0 100px #cc00cc;
  animation: countPop 0.9s ease-out forwards;
  line-height: 1;
}

@keyframes countPop {
  0%   { transform: scale(1.8); opacity: 0; }
  30%  { transform: scale(1.0); opacity: 1; }
  80%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}
