html {
  overflow: hidden;
  /* Improve performance on mobile */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Prevent horizontal scroll */
  max-width: 100vw;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(96, 96, 158, 0.95);
  
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    
  background-size: 60px 60px, 60px 60px, auto, auto, auto, auto, auto;
  pointer-events: none;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

#game-container {
  margin: 0 !important;
  padding: 0 !important;
  text-align: center;
  position: relative;
  overflow: hidden;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Game Control Buttons - Top Left */
.game-controls {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  display: flex;
  gap: 12px;
  flex-direction: column;
  max-width: 100vw;
}

.control-btn {
  background: linear-gradient(
    135deg,
    rgba(240, 147, 251, 0.9),
    rgba(245, 87, 108, 0.8)
  );
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 20px rgba(240, 147, 251, 0.4);
  color: #ffffff;
  position: relative;
  overflow: hidden;
}

.control-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.control-btn:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 0 30px rgba(240, 147, 251, 0.6);
}

.control-btn:hover::before {
  opacity: 1;
}

.control-btn:active {
  transform: translateY(-2px) scale(1.02);
}

.control-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  z-index: 1;
  position: relative;
}


/* Modal pop-up for game over */
#game-over-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  pointer-events: auto;
}

#game-over-modal .modal-content {
  background: #1a1a2e;
  border: 2px solid #16213e;
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}


#game-over-modal h1 {
  background: linear-gradient(
    135deg,
    #ff5e62,
    #ffb347,
    #36d1c4,
    #a18cd1
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 20px;
  font-size: 2.5rem;
  font-weight: bold;
  letter-spacing: 2px;
}

#game-over-modal h2 {
  color: #ffffff;
  margin-bottom: 24px;
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 1px;
}

#game-over-modal #final-score-modal {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 28px;
  margin: 24px 0;
  font-size: 2.8rem;
  font-weight: bold;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}


#game-over-modal #game-over-reason {
  color: #b0b0b0;
  margin-bottom: 30px;
}

#game-over-modal button {
  background: linear-gradient(
    135deg,
    rgba(240, 147, 251, 0.9),
    rgba(245, 87, 108, 0.8)
  );
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 18px 40px;
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  display: inline-block;
  margin: 16px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 20px rgba(240, 147, 251, 0.4);
  position: relative;
  overflow: hidden;
  text-align: center;
  min-width: 200px;
}


#game-over-modal button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#game-over-modal button:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 0 30px rgba(240, 147, 251, 0.6);
}

#game-over-modal button:hover::before {
  opacity: 1;
}

#game-over-modal button:active {
  transform: translateY(-2px) scale(1.02);
}

/* ===========================================
   RESPONSIVE DESIGN - COMPREHENSIVE BREAKPOINTS
   =========================================== */

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
  #game-container {
    padding: 0 4px;
    height: 100vh;
    justify-content: center;
    padding-top: 0;
    flex-direction: column;
  }

  #tubes {
    gap: 8px;
    padding: 0 4px;
    margin-bottom: 10px;
    order: 2;
  }

  .miss-progress {
    order: 1;
    margin-bottom: 10px;
  }

  #score-display {
    order: 3;
    position: static;
    transform: none;
    width: 100%;
    max-width: 100%;
    margin: 8px 0;
    flex-direction: row;
    justify-content: space-between;
    padding: 8px;
  }

  .score-item {
    flex: 1;
    margin: 0 2px;
    padding: 4px 6px;
    border-radius: 6px;
  }

  .game-controls {
    position: fixed;
    top: 5px;
    left: 5px;
    z-index: 100;
    display: flex;
    gap: 4px;
    flex-direction: column;
    max-width: 100vw;
  }

  .tube {
    width: 50px;
    height: 200px;
    min-width: 45px;
    min-height: 180px;
    border-radius: 8px 8px 12px 12px;
    border: 2px solid #23284a;
  }

  .tube-icon {
    width: 28px;
    height: 28px;
    bottom: 6px;
    border: 2px solid #fff2;
  }

  .tube-icon svg {
    width: 16px;
    height: 16px;
  }

  .ball {
    width: 20px;
    height: 20px;
  }

  .bullet {
    width: 4px;
    height: 4px;
  }

  /* Score display styles are now handled above in the main container */

  .score-label {
    font-size: 0.5rem;
    margin-bottom: 1px;
  }

  .score-value {
    font-size: 0.8rem;
  }

  .score-item.total .score-value {
    font-size: 1rem;
  }

  .miss-progress {
    max-width: 360px;
    gap: 4px;
    margin-bottom: 8px;
  }

  .progress-label {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .progress-bar {
    height: 10px;
  }

  /* Game controls styles are now handled above in the main container */

  .control-btn {
    width: 36px;
    height: 36px;
    min-width: 32px;
    min-height: 32px;
  }

  .control-btn svg {
    width: 14px;
    height: 14px;
  }


  .rule-card {
    padding: 15px;
  }


  #game-over-modal .modal-content {
    padding: 20px 15px;
    margin: 10px;
  }

  #game-over-modal button {
    padding: 15px 30px;
    font-size: 1.1rem;
    min-width: 180px;
  }
}

/* Mobile (≤640px) */
@media (min-width: 481px) and (max-width: 640px) {
  #game-container {
    padding: 0 8px;
    height: 100vh;
    justify-content: center;
    padding-top: 0;
  }

  #tubes {
    gap: 10px;
    padding: 0 8px;
    margin-bottom: 12px;
  }

  .tube {
    width: 50px;
    height: 200px;
    min-width: 45px;
    min-height: 180px;
    border-radius: 8px 8px 15px 15px;
    border: 2px solid #23284a;
  }

  .tube-icon {
    width: 28px;
    height: 28px;
    bottom: 6px;
    border: 2px solid #fff2;
  }

  .tube-icon svg {
    width: 14px;
    height: 14px;
  }

  .ball {
    width: 20px;
    height: 20px;
  }

  .bullet {
    width: 5px;
    height: 5px;
  }

  #score-display {
    width: 120px;
    min-width: 100px;
    max-width: 140px;
    padding: 10px;
    gap: 6px;
    top: 10px;
    right: 10px;
    border-radius: 12px;
  }

  .score-item {
    padding: 6px 8px;
    border-radius: 8px;
  }

  .score-label {
    font-size: 0.6rem;
    margin-bottom: 2px;
  }

  .score-value {
    font-size: 1rem;
  }

  .score-item.total .score-value {
    font-size: 1.2rem;
  }

  .miss-progress {
    max-width: 400px;
    gap: 6px;
    margin-bottom: 12px;
  }

  .progress-label {
    font-size: 0.8rem;
    margin-bottom: 6px;
  }

  .progress-bar {
    height: 12px;
  }

  .game-controls {
    top: 10px;
    left: 10px;
    gap: 8px;
  }

  .control-btn {
    width: 44px;
    height: 44px;
    min-width: 40px;
    min-height: 40px;
  }

  .control-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Home modal adjustments for mobile */

  .rules-section {
    padding: 20px;
  }

  #game-over-modal .modal-content {
    padding: 20px 28px;
    min-width: 250px !important;
    max-width: 320px !important;
    width: 320px !important;
  }
}

/* Tablet Portrait (641px-768px) */
@media (min-width: 641px) and (max-width: 768px) {
  #game-container {
    padding: 0 12px;
    height: 100vh;
    justify-content: center;
  }

  #tubes {
    gap: 8px;
    padding: 0 12px;
    margin-bottom: 18px;
  }

  .tube {
    width: 60px;
    height: 250px;
    min-width: 55px;
    min-height: 230px;
    border-radius: 10px 10px 18px 18px;
    border: 2px solid #23284a;
  }

  .tube-icon {
    width: 32px;
    height: 32px;
    bottom: 8px;
    border: 2px solid #fff2;
  }

  .tube-icon svg {
    width: 16px;
    height: 16px;
  }

  .ball {
    width: 22px;
    height: 22px;
  }

  .bullet {
    width: 6px;
    height: 6px;
  }

  #score-display {
    width: 140px;
    min-width: 120px;
    max-width: 160px;
    padding: 12px;
    gap: 6px;
    top: 15px;
    right: 15px;
    border-radius: 16px;
  }

  .score-item {
    padding: 8px 10px;
    border-radius: 10px;
  }

  .score-label {
    font-size: 0.65rem;
    margin-bottom: 3px;
  }

  .score-value {
    font-size: 1.1rem;
  }

  .score-item.total .score-value {
    font-size: 1.4rem;
  }

  .miss-progress {
    max-width: 480px;
    gap: 8px;
    margin-bottom: 18px;
  }

  .progress-label {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .progress-bar {
    height: 13px;
  }

  .game-controls {
    top: 15px;
    left: 15px;
    gap: 10px;
  }

  .control-btn {
    width: 48px;
    height: 48px;
    min-width: 44px;
    min-height: 44px;
  }

  .control-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Home modal adjustments for tablet portrait */

  .rules-section {
    padding: 25px;
  }

  #game-over-modal .modal-content {
    padding: 24px 32px;
    min-width: 250px !important;
    max-width: 340px !important;
    width: 340px !important;
  }
}

/* Tablet Landscape (769px-1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  #game-container {
    padding: 0 20px;
    height: 100vh;
    justify-content: center;
  }

  #tubes {
    gap: 15px;
    padding: 0 20px;
    margin-bottom: 20px;
  }

  .tube {
    width: 60px;
    height: 250px;
    min-width: 55px;
    min-height: 230px;
    border-radius: 10px 10px 18px 18px;
    border: 2px solid #23284a;
  }

  .tube-icon {
    width: 32px;
    height: 32px;
    bottom: 8px;
    border: 2px solid #fff2;
  }

  .tube-icon svg {
    width: 16px;
    height: 16px;
  }

  .ball {
    width: 22px;
    height: 22px;
  }

  .bullet {
    width: 6px;
    height: 6px;
  }

  #score-display {
    width: 160px;
    min-width: 140px;
    max-width: 180px;
    padding: 15px;
    gap: 8px;
    top: 20px;
    right: 20px;
    border-radius: 20px;
  }

  .score-item {
    padding: 10px 12px;
    border-radius: 12px;
  }

  .score-label {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .score-value {
    font-size: 1.2rem;
  }

  .score-item.total .score-value {
    font-size: 1.5rem;
  }

  .miss-progress {
    max-width: 550px;
    gap: 8px;
    margin-bottom: 20px;
  }

  .progress-label {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  .progress-bar {
    height: 14px;
  }

  .game-controls {
    top: 20px;
    left: 20px;
    gap: 12px;
  }

  .control-btn {
    width: 52px;
    height: 52px;
    min-width: 48px;
    min-height: 48px;
  }

  .control-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Home modal adjustments for tablet landscape */

  .rules-section {
    padding: 30px;
  }

  #game-over-modal .modal-content {
    padding: 28px 36px;
    min-width: 250px !important;
    max-width: 360px !important;
    width: 360px !important;
  }
}

/* Desktop (≥1025px) */
@media (min-width: 1025px) {
  #game-container {
    padding: 0 20px;
    height: 100vh;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
  }

  #tubes {
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    max-width: 100%;
  }

  .tube {
    width: 80px;
    height: 350px;
    min-width: 70px;
    min-height: 320px;
    border-radius: 20px 20px 40px 40px;
    border: 3px solid #23284a;
  }

  .tube-icon {
    width: 40px;
    height: 40px;
    bottom: 15px;
    border: 3px solid #fff2;
  }

  .tube-icon svg {
    width: 20px;
    height: 20px;
  }

  .ball {
    width: 28px;
    height: 28px;
  }

  .bullet {
    width: 8px;
    height: 8px;
  }

  #score-display {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    min-width: 300px;
    max-width: 360px;
    padding: 35px;
    gap: 20px;
    border-radius: 36px;
    border: 5px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 40px 140px rgba(0, 0, 0, 0.6),
      0 0 70px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  .score-item {
    padding: 30px 35px;
    border-radius: 28px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  .score-label {
    font-size: 1.3rem;
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  }

  .score-value {
    font-size: 2rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  }

  .score-item.total .score-value {
    font-size: 3rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  }

  .miss-progress {
    max-width: 1000px;
    gap: 20px;
    margin-bottom: 30px;
  }

  .progress-label {
    font-size: 1.8rem;
    margin-bottom: 20px;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  }

  .progress-bar {
    height: 30px;
    border-radius: 18px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .game-controls {
    top: 20px;
    left: 20px;
    gap: 12px;
  }

  .control-btn {
    width: 52px;
    height: 52px;
    min-width: 48px;
    min-height: 48px;
  }

  .control-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Home modal adjustments for desktop */

  .rules-section {
    padding: 40px;
  }

  #game-over-modal .modal-content {
    padding: 32px 40px;
    min-width: 250px !important;
    max-width: 380px !important;
    width: 380px !important;
  }
}

/* Extra Large Desktop Screens (≥1400px) */
@media (min-width: 1400px) {
  #tubes {
    gap: 25px;
    justify-content: center;
    margin-bottom: 35px;
    flex-wrap: wrap;
    max-width: 100%;
  }

  .tube {
    width: 90px;
    height: 400px;
    min-width: 80px;
    min-height: 370px;
    border-radius: 22px 22px 45px 45px;
    border: 3px solid #23284a;
  }

  .tube-icon {
    width: 45px;
    height: 45px;
    bottom: 18px;
    border: 3px solid #fff2;
  }

  .tube-icon svg {
    width: 22px;
    height: 22px;
  }

  .ball {
    width: 32px;
    height: 32px;
  }

  .bullet {
    width: 9px;
    height: 9px;
  }

  #score-display {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 360px;
    min-width: 340px;
    max-width: 400px;
    padding: 40px;
    gap: 25px;
    border-radius: 40px;
    border: 6px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 45px 160px rgba(0, 0, 0, 0.6),
      0 0 80px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  .score-item {
    padding: 35px 40px;
    border-radius: 32px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  .score-label {
    font-size: 1.5rem;
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  }

  .score-value {
    font-size: 2.2rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  }

  .score-item.total .score-value {
    font-size: 3.4rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  }

  .miss-progress {
    max-width: 1100px;
    gap: 25px;
    margin-bottom: 35px;
  }

  .progress-label {
    font-size: 2rem;
    margin-bottom: 25px;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  }

  .progress-bar {
    height: 35px;
    border-radius: 20px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .game-controls {
    top: 20px;
    left: 20px;
    gap: 12px;
  }

  .control-btn {
    width: 60px;
    height: 60px;
    min-width: 56px;
    min-height: 56px;
  }

  .control-btn svg {
    width: 24px;
    height: 24px;
  }
}

/* Additional Mobile Touch Improvements */
@media (max-width: 768px) {
  /* Improve touch targets */
  .tube {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }

  /* Better touch feedback */
  .tube:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }

  /* Prevent zoom on double tap */
  .control-btn {
    touch-action: manipulation;
  }

  /* Improve text readability on small screens */
  .score-label {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  /* Better button spacing for touch */
  .game-controls {
    touch-action: manipulation;
  }
}

/* Landscape Mobile (orientation: landscape) */
@media (orientation: landscape) and (max-height: 500px) {
  #game-container {
    height: 100vh;
    justify-content: flex-start;
    padding-top: 8px;
    flex-direction: row;
    align-items: center;
    gap: 25px;
  }

  #tubes {
    flex-direction: row;
    gap: 5px;
    margin-bottom: 0;
    flex: 1;
    max-width: 75%;
  }

  .tube {
    height: 160px;
    min-height: 140px;
    width: 70px;
    min-width: 60px;
    border-radius: 10px 10px 18px 18px;
    border: 2px solid #23284a;
  }

  .tube-icon {
    width: 32px;
    height: 32px;
    bottom: 6px;
    border: 2px solid #fff2;
  }

  .tube-icon svg {
    width: 16px;
    height: 16px;
  }

  .ball {
    width: 24px;
    height: 24px;
  }

  .bullet {
    width: 5px;
    height: 5px;
  }

  #score-display {
    position: static;
    transform: none;
    width: 140px;
    min-width: 120px;
    max-width: 160px;
    padding: 12px;
    gap: 6px;
    margin: 0;
    order: -1;
    border-radius: 16px;
  }

  .score-item {
    padding: 6px 8px;
    border-radius: 8px;
  }

  .score-label {
    font-size: 0.6rem;
    margin-bottom: 2px;
  }

  .score-value {
    font-size: 1rem;
  }

  .score-item.total .score-value {
    font-size: 1.2rem;
  }

  .miss-progress {
    max-width: 350px;
    gap: 6px;
    margin-bottom: 10px;
    order: -2;
  }

  .progress-label {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .progress-bar {
    height: 10px;
  }

  .game-controls {
    top: 8px;
    left: 8px;
    gap: 6px;
  }

  .control-btn {
    width: 40px;
    height: 40px;
    min-width: 36px;
    min-height: 36px;
  }

  .control-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Home modal adjustments for landscape mobile */


  .rule-card {
    padding: 10px;
  }

  #game-over-modal .modal-content {
    padding: 15px 25px;
    min-width: 250px;
    width: 90%;
  }

  #game-over-modal button {
    width: 48px;
    height: 48px;
    margin: 8px;
  }

  #game-over-modal button svg {
    width: 18px;
    height: 18px;
  }
}

/* Extra Small Screens (≤320px) - Very small phones */
@media (max-width: 320px) {
  #game-container {
    padding: 0 2px;
    height: 100vh;
    justify-content: center;
    padding-top: 0;
    flex-direction: column;
  }

  #tubes {
    gap: 5px;
    padding: 0 2px;
    margin-bottom: 6px;
    order: 2;
  }

  .miss-progress {
    order: 1;
    margin-bottom: 6px;
  }

  #score-display {
    order: 3;
    position: static;
    transform: none;
    width: 100%;
    max-width: 100%;
    margin: 4px 0;
    flex-direction: row;
    justify-content: space-between;
    padding: 6px;
  }

  .score-item {
    flex: 1;
    margin: 0 1px;
    padding: 3px 4px;
    border-radius: 4px;
  }

  .game-controls {
    position: fixed;
    top: 2px;
    left: 2px;
    z-index: 100;
    display: flex;
    gap: 3px;
    flex-direction: column;
    max-width: 100vw;
  }

  .tube {
    width: 40px;
    height: 160px;
    min-width: 35px;
    min-height: 140px;
    border-radius: 6px 6px 10px 10px;
  }

  .tube-icon {
    width: 24px;
    height: 24px;
    bottom: 4px;
  }

  .tube-icon svg {
    width: 12px;
    height: 12px;
  }

  .ball {
    width: 16px;
    height: 16px;
  }

  .bullet {
    width: 3px;
    height: 3px;
  }

  /* Score display styles are now handled above in the main container */

  .score-label {
    font-size: 0.4rem;
    margin-bottom: 1px;
  }

  .score-value {
    font-size: 0.7rem;
  }

  .score-item.total .score-value {
    font-size: 0.9rem;
  }

  .miss-progress {
    max-width: 320px;
    gap: 3px;
    margin-bottom: 6px;
  }

  .progress-label {
    font-size: 0.6rem;
    margin-bottom: 3px;
  }

  .progress-bar {
    height: 8px;
  }

  /* Game controls styles are now handled above in the main container */

  .control-btn {
    width: 32px;
    height: 32px;
    min-width: 28px;
    min-height: 28px;
  }

  .control-btn svg {
    width: 12px;
    height: 12px;
  }

  /* Home modal adjustments for extra small screens */

  .rule-card {
    padding: 10px;
  }


  #game-over-modal .modal-content {
    padding: 12px 20px;
    min-width: 250px !important;
    max-width: 280px !important;
    width: 280px !important;
  }

  #game-over-modal button {
    width: 48px;
    height: 48px;
    margin: 8px;
  }

  #game-over-modal button svg {
    width: 18px;
    height: 18px;
  }
}

/* Performance optimizations for all devices */
* {
  box-sizing: border-box;
}

.tube, .ball, .bullet, .bubble-piece, .burst-effect, .mini-burst-effect, .gun-effect {
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Smooth animations */
.ball, .bullet {
  transition: transform 0.1s ease-out;
}

/* Prevent text selection on game elements */
.tube, .control-btn, .score-item {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Startup Modal Styles */
.startup-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

/* Hide game controls and score panel when startup modal is visible */
.startup-modal-visible .game-controls,
.startup-modal-visible #score-display {
  display: none !important;
}

.startup-content {
  background: #1a1a2e;
  border: 2px solid #16213e;
  border-radius: 20px;
  padding: 40px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  color: #ffffff;
}

.game-logo {
  margin-bottom: 30px;
}


.game-logo h1 {
  font-size: 3rem;
  font-weight: bold;
  margin: 0 0 10px 0;
  background: linear-gradient(
    135deg,
    #ff5e62,
    #ffb347,
    #36d1c4,
    #a18cd1
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: 2px;
}

.tagline {
  font-size: 1.2rem;
  color: #a0a0a0;
  margin: 0;
  font-style: italic;
}

.game-rules {
  margin-bottom: 30px;
}

.game-rules h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #ffffff;
  border-bottom: 2px solid #16213e;
  padding-bottom: 10px;
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  text-align: left;
  background: #16213e;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #0f3460;
}

.rule-icon {
  font-size: 2rem;
  flex-shrink: 0;
  margin-top: 5px;
}

.rule-text h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  color: #ffffff;
  font-weight: bold;
}

.rule-text p {
  margin: 0;
  font-size: 0.9rem;
  color: #b0b0b0;
  line-height: 1.4;
}

.controls-info {
  margin-bottom: 30px;
}

.controls-info h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #ffffff;
  border-bottom: 2px solid #16213e;
  padding-bottom: 10px;
}

.controls-grid {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 15px;
}

.control-key {
  background: #0f3460;
  color: #ffffff;
  border: 2px solid #16213e;
  border-radius: 8px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  font-family: monospace;
}

.controls-note {
  font-size: 0.9rem;
  color: #a0a0a0;
  margin: 0;
  font-style: italic;
}

.startup-actions {
  margin-top: 20px;
}

.start-btn {
  background: linear-gradient(
    135deg,
    rgba(240, 147, 251, 0.9),
    rgba(245, 87, 108, 0.8)
  );
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 18px 40px;
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  display: inline-block;
  margin: 0 auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 20px rgba(240, 147, 251, 0.4);
  text-align: center;
  min-width: 200px;
  position: relative;
  overflow: hidden;
}

.start-btn:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 0 30px rgba(240, 147, 251, 0.6);
}

.start-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 50px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.start-btn:hover::before {
  opacity: 1;
}

.start-btn:active {
  transform: translateY(-2px) scale(1.02);
}


/* Responsive Design for Startup Modal */
@media (max-width: 768px) {
  .startup-content {
    padding: 30px 20px;
    margin: 10px;
  }
  
  .game-logo h1 {
    font-size: 2.2rem;
  }
  
  .rules-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .rule-item {
    padding: 15px;
  }
  
  .controls-grid {
    gap: 10px;
  }
  
  .control-key {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
  
  .start-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .startup-content {
    padding: 20px 15px;
  }
  
  .game-logo h1 {
    font-size: 1.8rem;
  }
  
  .game-rules h2,
  .controls-info h2 {
    font-size: 1.4rem;
  }
  
  .rule-item {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .rule-icon {
    margin-top: 0;
  }
}

/* Remove old unused styles */

#score-display {
  position: fixed;
  top: 10px;
  right: 10px;
  transform: none;
  z-index: 50;
  width: 120px;
  min-width: 100px;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 15, 35, 0.9);
  backdrop-filter: blur(30px);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}


.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.score-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.score-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.score-item:hover::before {
  opacity: 1;
}

.score-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.score-item:hover::before {
  opacity: 1;
}

.score-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.score-item.positive {
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.2),
    rgba(22, 163, 74, 0.15)
  );
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(34, 197, 94, 0.2);
}

.score-item.negative {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.2),
    rgba(220, 38, 38, 0.15)
  );
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(239, 68, 68, 0.2);
}

.score-item.total {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.25),
    rgba(217, 119, 6, 0.2)
  );
  border-color: rgba(245, 158, 11, 0.5);
  border-width: 2px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(245, 158, 11, 0.3),
    0 0 0 1px rgba(245, 158, 11, 0.3);
  transform: scale(1.05);
  order: -1;
  animation: totalGlow 3s ease-in-out infinite alternate;
}

@keyframes totalGlow {
  0% {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(245, 158, 11, 0.3),
      0 0 0 1px rgba(245, 158, 11, 0.3);
  }
  100% {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 40px rgba(245, 158, 11, 0.5),
      0 0 0 1px rgba(245, 158, 11, 0.5);
  }
}


.score-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.score-value {
  font-size: 1rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  font-family: "Courier New", monospace;
}

.score-item.total .score-value {
  font-size: 1.2rem;
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  font-weight: 900;
}

.miss-progress {
  display: flex;
  flex-direction: column;
  text-align: center;
  /* Gap and margin handled by media queries */
  max-width: 300px;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.progress-label {
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}



#tubes {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  flex-shrink: 0;
  /* Gap and padding handled by media queries */
}

.tube {
  background: linear-gradient(180deg, #23284a 60%, #23284a 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-shadow: 0 4px 32px 0 #181c2faa, 0 0 24px 4px #ffb34733;
  transition: box-shadow 0.2s, border-color 0.2s;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  /* Sizing handled by media queries only */
}
.tube:active,
.tube.glow,
.tube.touch-active {
  box-shadow: 0 0 40px 10px #fff, 0 0 80px 20px #ff5e62;
  border-color: #fff;
  transform: scale(0.98);
}

/* Mobile touch feedback */
@media (max-width: 768px) {
  .tube:active,
  .tube.touch-active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

.tube-icon {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px #ffb34755, 0 0 16px #ff5e62aa;
  z-index: 10;
  transition: box-shadow 0.2s, border-color 0.2s;
  /* Sizing handled by media queries only */
}

/* Mobile touch indicator */
@media (max-width: 768px) {
  .tube-icon {
    animation: mobilePulse 2s ease-in-out infinite;
  }
}

@keyframes mobilePulse {
  0%,
  100% {
    box-shadow: 0 2px 12px #ffb34755, 0 0 16px #ff5e62aa;
  }
  50% {
    box-shadow: 0 2px 16px #ffb34788, 0 0 24px #ff5e62cc;
  }
}
.tube-icon svg {
  display: block;
}

/* Smaller, slower, more energetic ball */
.ball {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: radial-gradient(
    circle at 30% 30%,
    #fff 0%,
    #ffb347 60%,
    #ff5e62 100%
  );
  border-radius: 50%;
  /* Remove default border - only show when absorbing */
  z-index: 2;
  animation: pop 0.2s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  /* Remove shadow */
}

/* Bullet absorption effect */
.ball.absorbing {
  border: 4px solid #fff;
  box-shadow: 0 0 20px 8px #fff8, 0 0 40px 16px #ffb34788;
  animation: absorb 0.3s ease-out, blinkBorder 0.3s ease-out;
}

@keyframes absorb {
  0% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.1);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes blinkBorder {
  0% {
    border-color: #fff;
  }
  25% {
    border-color: #ffb347;
  }
  50% {
    border-color: #ff5e62;
  }
  75% {
    border-color: #36d1c4;
  }
  100% {
    border-color: #fff;
  }
}

/* Bubble burst effect */
.burst-effect {
  position: absolute;
  width: 64px;
  height: 64px;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(circle, #fff 0%, #ff5e62 40%, transparent 80%);
  opacity: 0.8;
  animation: burstAnim 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  box-shadow: 0 0 32px 8px #fff8, 0 0 64px 16px #ff5e6288;
}

@keyframes burstAnim {
  0% {
    opacity: 1;
    transform: scale(0.5);
  }
  60% {
    opacity: 0.9;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(2.2);
  }
}

/* Gun/muzzle flash effect at the bottom of the tube */
.gun-effect {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 36px;
  height: 36px;
  background: radial-gradient(
    circle,
    #fff 0%,
    #ffb347 40%,
    #ff5e62 80%,
    transparent 100%
  );
  border-radius: 50%;
  transform: translateX(-50%) scale(1.3);
  opacity: 0.95;
  z-index: 20;
  pointer-events: none;
  animation: gunFlash 0.18s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  box-shadow: 0 0 32px 8px #fff8, 0 0 64px 16px #ff5e6288;
  border: 2px solid #fff;
}
@keyframes gunFlash {
  0% {
    opacity: 1;
    transform: translateX(-50%) scale(1.3);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(2.2);
  }
}

#game-over {
  margin-top: 24px;
  animation: fadeIn 0.7s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}



/* Bullet fired from the bottom of the tube */
.bullet {
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, #fff 0%, #ffb347 60%, #ff5e62 100%);
  border-radius: 50%;
  position: fixed;
  z-index: 10;
  animation: bulletFire 0.3s ease-out;
  box-shadow: 0 0 8px 3px #ffb347cc;
}
@keyframes bulletFire {
  0% {
    opacity: 0.7;
    transform: translateX(-50%) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

/* Mini burst effect for first hit */
.mini-burst-effect {
  position: absolute;
  width: 32px;
  height: 32px;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 12;
  background: radial-gradient(
    circle,
    #fff 0%,
    #ffb347 40%,
    #ff5e62 80%,
    transparent 100%
  );
  opacity: 0.7;
  animation: miniBurstAnim 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  box-shadow: 0 0 16px 4px #ffb34788;
}
@keyframes miniBurstAnim {
  0% {
    opacity: 1;
    transform: scale(0.5);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.tube.miss-effect {
  animation: missFlash 0.3s;
  border-color: #ff2222 !important;
  box-shadow: 0 0 40px 10px #ff2222, 0 0 80px 20px #ff5e62;
}
@keyframes missFlash {
  0% {
    border-color: #ff2222;
    box-shadow: 0 0 40px 10px #ff2222, 0 0 80px 20px #ff5e62;
  }
  100% {
    border-color: #ff5e62;
    box-shadow: 0 4px 32px 0 #ff5e62aa, 0 0 24px 4px #ffb34755;
  }
}

.bubble-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 1;
  pointer-events: none;
  z-index: 30;
  box-shadow: 0 0 8px 2px #fff8, 0 0 16px 4px #ffb34788;
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.5s;
  will-change: transform, opacity;
}




