 * { 
      box-sizing: border-box;
     }
    html, body {
      margin: 0; padding: 0; height: 100%;
      font-family: sans-serif;
      overflow: hidden;
      background-color: #f0f8ff;
    }
    body {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    header {
      text-align: center;
      font-size: clamp(16px, 2.5vw, 32px);
      font-weight: bold;
      padding: 10px;
    }
    main {
      position: relative;
      border: 2px solid black;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 90%;
      max-width: 900px;
      aspect-ratio: 9 / 4.5;
      background-color: white;
    }
    #gameCanvas {
      width: 100%;
      height: 100%;
      display: block;
      touch-action: none;
    }
    .button-container {
      width: 90%;
      max-width: 900px;
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
      flex-wrap: wrap;
    }
    button {
      width: 107px;
      height: 50px;
      font-size: 16px;
      background-color: white;
      border: 2px solid black;
      box-shadow: 5px 5px 0px black;
      cursor: pointer;
      font-weight: bold;
      margin: 5px;
      transition: transform 0.1s ease;
    }
    button:active {
      transform: translate(2px, 2px);
      box-shadow: 3px 3px 0px black;
    }
    #score, #timer, #topScore {
      font-size: 18px;
      margin: 5px 20px;
      font-weight: bold;
    }
    #startPopup {
      position: absolute;
      top: 40%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: #fff;
      border: 2px solid black;
      padding: 20px 40px;
      font-size: 24px;
      font-weight: bold;
      display: block;
      z-index: 2;
    }

    #popup, #scorePopup {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid black;
  padding: 20px 40px;
  font-weight: bold;
  display: none;
  z-index: 2;
}

#popup {
  top: 30%;
  background: #fff;
  font-size: 24px;
  z-index: 3;
}

#scorePopup {
  top: 50%;
  background: rgba(0, 255, 0, 0.7);
  font-size: 18px;
}

  #leaderboard {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 30px 40px;
  border-radius: 20px;
  display: none;
  z-index: 3;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  width: 340px;
  font-family: 'Segoe UI', sans-serif;
}

#leaderboard h3 {
  margin: 0 0 20px 0;
  font-size: 26px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid rgba(255,255,255,0.3);
  padding-bottom: 10px;
}

#leaderboard ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}

#leaderboard ul li {
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  color: #f9fafb;
}

#leaderboard ul li:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.02);
}

#leaderboard ul li span.position {
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: #fcd34d;
}

#leaderboard ul li span.score {
  font-size: 18px;
  font-weight: 600;
}

#leaderboard ul li.top-score {
  background: rgba(255, 255, 255, 0.25);
  color: #facc15;
  font-size: 18px;
  border: 2px solid #facc15;
  box-shadow: 0 0 10px #facc15;
}

#leaderboard button {
  margin-top: 20px;
  background-color: white;
  color: #1e3a8a;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  width: auto;
  height: auto;
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s ease, transform 0.1s ease;
}

#leaderboard button:hover {
  background-color: #fcd34d;
  transform: translateY(-2px);
}

#leaderboard ul::-webkit-scrollbar {
  width: 5px;
}
#leaderboard ul::-webkit-scrollbar-track {
  background: transparent;
}
#leaderboard ul::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}
#newHighScoreBadge {
  display: none;
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: gold;
  padding: 15px 30px;
  border: 3px solid black;
  font-size: 24px;
  font-weight: bold;
  z-index: 4;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
#instructions {
      display:none;
      position: absolute;
      top: 10%;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(0, 0, 0, 0.7);
      color: white;
      padding: 20px;
      border-radius: 10px;
      z-index: 3;
    }