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

body {
  overflow: hidden;
  background: #0a1a0a;
  user-select: none;
  -webkit-user-select: none;
  font-family: Montserrat, Arial, sans-serif;
}

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: none;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.9) 100%);
  z-index: 10;
}

/* HUD */
#hud {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}

#score-display {
  font-size: 2.8rem;
  font-weight: 900;
  color: white;
  font-family: 'Arial Black', 'Arial', sans-serif;
  text-shadow: 0 0 30px rgba(145, 255, 145, 0.34), 2px 2px 6px rgba(0, 0, 0, 0.9);
  letter-spacing: 2px;
  min-width: 120px;
  transition: transform 0.16s, color 0.16s, text-shadow 0.16s;
}

#score-display.score-pop {
  color: #d5ff75;
  transform: scale(1.12);
  text-shadow: 0 0 32px rgba(210, 255, 110, 0.85), 2px 2px 6px rgba(0, 0, 0, 0.9);
}

#lives-display {
  display: flex;
  gap: 6px;
  font-size: 2rem;
}

.life {
  transition: opacity 0.3s, filter 0.3s, transform 0.3s;
  display: inline-block;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.life.hit {
  animation: life-hit 0.34s ease-out;
}

.life.lost {
  opacity: 0.2;
  filter: grayscale(1);
  transform: scale(0.8);
}

/* Combo display */
#combo-display {
  position: fixed;
  top: var(--combo-y, 40%);
  left: var(--combo-x, 50%);
  transform: translate(-50%, -50%) scale(0.86);
  z-index: 30;
  font-size: clamp(1.45rem, 5vw, 2.55rem);
  font-weight: 900;
  color: #ffdd00;
  font-family: 'Arial Black', 'Arial', sans-serif;
  text-shadow: 0 0 30px rgba(255, 220, 0, 0.9), 2px 2px 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
}

#combo-display.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#feedback-layer {
  position: fixed;
  inset: 0;
  z-index: 35;
  overflow: hidden;
  pointer-events: none;
}

.floating-feedback {
  position: absolute;
  left: var(--feedback-x);
  top: var(--feedback-y);
  color: var(--feedback-color, #ffffff);
  font-family: 'Arial Black', 'Arial', sans-serif;
  font-size: var(--feedback-size, 1.1rem);
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 0 18px currentColor, 2px 2px 6px rgba(0, 0, 0, 0.85);
  transform: translate(-50%, -50%);
  animation: feedback-float 0.72s ease-out forwards;
  white-space: nowrap;
}

/* Buttons */
.button-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  z-index: 30;
  display: flex;
  gap: 10px;
}

.game-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.game-button:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.game-button:active {
  transform: translateY(0) scale(0.96);
}

.game-button:focus-visible,
.btn-primary:focus-visible,
.sf-close-btn:focus-visible {
  outline: 3px solid rgba(180, 255, 120, 0.75);
  outline-offset: 3px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(34, 90, 34, 0.22), rgba(0, 0, 0, 0.88) 62%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

.modal-content {
  background:
    linear-gradient(145deg, rgba(20, 54, 20, 0.7), rgba(4, 18, 6, 0.72)),
    rgba(10, 30, 10, 0.55);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(145, 255, 145, 0.24);
  border-radius: 18px;
  padding: 36px 32px;
  max-width: 420px;
  width: 92%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  text-align: center;
  color: white;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.7), 0 0 38px rgba(70, 220, 70, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.modal-content h2 {
  font-size: 2.2rem;
  font-weight: 900;
  margin-bottom: 12px;
  color: #90ff90;
  text-shadow: 0 0 25px rgba(100, 255, 100, 0.6);
  font-family: 'Arial Black', 'Arial', sans-serif;
  letter-spacing: 1px;
}

.modal-desc {
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 700;
}

.rules {
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.rule {
  padding: 5px 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  line-height: 1.4;
}

.score-stats {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 22px;
}

.score-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 14px 28px;
  flex: 1;
}

.score-stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.score-stat-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: #90ff90;
  font-family: 'Arial Black', 'Arial', sans-serif;
}

.new-highscore-badge {
  background: linear-gradient(135deg, #ffaa00, #ff6600);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 14px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 4px 15px rgba(255, 150, 0, 0.4);
  animation: pulse-badge 1s ease-in-out infinite alternate;
}

@keyframes pulse-badge {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.btn-primary {
  background: linear-gradient(135deg, #62b94e, #25722b) !important;
  border-color: rgba(165, 255, 130, 0.25) !important;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 1rem;
  box-shadow: 0 10px 28px rgba(43, 145, 43, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #77cf61, #2d8a2d) !important;
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(59, 175, 59, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Outline button (Home / Bestenliste) */
.sf-btn-outline {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: rgba(255, 255, 255, 0.85) !important;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s !important;
}

.sf-btn-outline:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
  color: white !important;
}

/* Close button */
.sf-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}

.sf-close-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Leaderboard list */
.sf-lb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sf-lb-item:last-child {
  border-bottom: none;
}

.sf-lb-item.sf-lb-me {
  background: rgba(100, 255, 100, 0.08);
  border-radius: 8px;
  padding-left: 8px;
  padding-right: 8px;
}

.sf-lb-rank {
  width: 32px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sf-lb-name {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: white;
}

.sf-lb-score {
  font-weight: 900;
  font-size: 1rem;
  color: #90ff90;
  flex-shrink: 0;
}

.sf-muted {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.9rem;
}

@keyframes feedback-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.84);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -55%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(0.96);
  }
}

@keyframes life-hit {
  0% { transform: scale(1); }
  35% { transform: scale(1.28) rotate(-10deg); }
  100% { transform: scale(1); }
}

@media (max-width: 640px) {
  #hud {
    padding: 12px max(14px, env(safe-area-inset-right, 0px)) 12px max(14px, env(safe-area-inset-left, 0px));
  }

  #score-display {
    font-size: 2.15rem;
    min-width: 80px;
  }

  #lives-display {
    gap: 2px;
    font-size: 1.55rem;
  }

  .button-container {
    right: 50%;
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    transform: translateX(50%);
  }

  .game-button {
    width: 48px;
    height: 48px;
  }

  .modal-content {
    padding: 28px 22px;
    border-radius: 16px;
    width: min(94vw, 420px);
  }

  .modal-content h2 {
    font-size: 1.9rem;
  }

  .rules {
    padding: 12px 14px;
  }

  .score-stat {
    padding: 12px 16px;
  }

  .score-stat-value {
    font-size: 1.75rem;
  }
}

@media (max-height: 560px) {
  .modal-overlay {
    align-items: flex-start;
  }

  .modal-content {
    padding-top: 24px;
    padding-bottom: 24px;
  }
}
