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

body {
  overflow: hidden;
  background: #050510;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 420px);
  height: 100vh;
  touch-action: none;
}

/* Sidebar letterboxing on desktop */
body::before,
body::after {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  width: calc((100vw - 420px) / 2);
  background: #020208;
  z-index: 1;
}
body::before { left: 0; }
body::after  { right: 0; }

/* HUD */
#hud {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 420px);
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 24px;
  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(255, 255, 255, 0.4), 2px 2px 6px rgba(0, 0, 0, 0.9);
  letter-spacing: 2px;
  min-width: 120px;
}

#highscore-display {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Arial Black', 'Arial', sans-serif;
  text-align: right;
  line-height: 1.4;
}

#highscore-display span {
  display: block;
  font-size: 1.4rem;
  color: #aad4ff;
  text-shadow: 0 0 20px rgba(100, 180, 255, 0.5);
}

/* Buttons */
.button-container {
  position: fixed;
  bottom: 24px;
  right: max(24px, calc((100vw - 420px) / 2 + 24px));
  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);
  transition: background 0.2s, border-color 0.2s;
}

.game-button:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}


/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.modal-content {
  background: rgba(5, 10, 30, 0.75);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(100, 160, 255, 0.2);
  border-radius: 20px;
  padding: 36px 32px;
  max-width: 420px;
  width: 92%;
  text-align: center;
  color: white;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

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

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

.rules {
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 4px;
}

.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: #aad4ff;
  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, #1a4a8a, #0a2a5a) !important;
  border-color: #2a6acc !important;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 1rem;
  transition: background 0.2s, transform 0.1s !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2a5aaa, #1a4a8a) !important;
  transform: translateY(-1px);
}

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

/* Close button */
.sh-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;
}

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

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

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

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

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

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

.sh-lb-score {
  font-weight: 900;
  font-size: 1rem;
  color: #aad4ff;
  flex-shrink: 0;
}

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