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

body {
  overflow: hidden;
  background: #2e4a30; /* forest fallback before canvas paints */
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
}

/* Canvas spans the full window so the forest fills the sides; gameplay is
   kept inside a centered 420px column by the game code itself. */
#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

/* 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: 800;
  color: #ffffff;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  /* dark-green outline so it reads on bright sky or dark forest */
  text-shadow:
    -2px -2px 0 #2c5226, 2px -2px 0 #2c5226,
    -2px  2px 0 #2c5226, 2px  2px 0 #2c5226,
    0 4px 8px rgba(20, 40, 20, 0.5);
  letter-spacing: 1px;
  min-width: 120px;
}

#highscore-display {
  font-size: 1rem;
  font-weight: 700;
  color: #fff7e0;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  text-align: right;
  line-height: 1.4;
  text-shadow: 0 2px 4px rgba(20, 40, 20, 0.6);
}

#highscore-display span {
  display: block;
  font-size: 1.4rem;
  color: #ffd86b;
  text-shadow: 0 2px 6px rgba(60, 40, 0, 0.6);
}

/* 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, 247, 224, 0.5);
  background: rgba(56, 86, 52, 0.72);
  color: #fff7e0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 3px 10px rgba(20, 40, 20, 0.45);
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.game-button:hover {
  background: rgba(96, 140, 80, 0.85);
  border-color: #fff7e0;
}

.game-button:active {
  transform: translateY(1px);
}


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

.modal-content {
  background: linear-gradient(165deg, #fdf4dd, #f2e1bd);
  border: 3px solid #b9894c;
  border-radius: 22px;
  padding: 34px 30px;
  max-width: 420px;
  width: 92%;
  text-align: center;
  color: #4a3a22;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  box-shadow: 0 14px 44px rgba(20, 40, 20, 0.55),
              inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

.modal-content h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: #3a7a2c;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  letter-spacing: 0.5px;
}

.modal-desc {
  color: #6a5638;
  margin-bottom: 16px;
  font-size: 1rem;
}

.rules {
  text-align: left;
  background: rgba(96, 140, 80, 0.16);
  border: 1px solid rgba(120, 90, 50, 0.25);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 4px;
}

.rule {
  padding: 5px 0;
  color: #4a3a22;
  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(96, 140, 80, 0.16);
  border: 1px solid rgba(120, 90, 50, 0.22);
  border-radius: 12px;
  padding: 14px 28px;
  flex: 1;
}

.score-stat-label {
  font-size: 0.75rem;
  color: #8a7350;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.score-stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: #3a7a2c;
  font-family: 'Baloo 2', 'Trebuchet MS', 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, #6fc24a, #3f8f2a) !important;
  border-color: #2f7a22 !important;
  color: #fff !important;
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 1.05rem;
  text-shadow: 0 1px 2px rgba(20, 50, 15, 0.5);
  box-shadow: 0 4px 0 #2f7a22, 0 6px 12px rgba(20, 40, 20, 0.35);
  transition: background 0.2s, transform 0.1s, box-shadow 0.1s !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #7ed257, #469c31) !important;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2f7a22, 0 2px 6px rgba(20, 40, 20, 0.35) !important;
}

/* Close button */
.sh-close-btn {
  background: none;
  border: none;
  color: #8a7350;
  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: #4a3a22;
  background: rgba(120, 90, 50, 0.15);
}

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

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

.sh-lb-item.sh-lb-me {
  background: rgba(96, 140, 80, 0.22);
  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: #4a3a22;
}

.sh-lb-score {
  font-weight: 800;
  font-size: 1rem;
  color: #3a7a2c;
  flex-shrink: 0;
}

.sh-muted {
  color: #8a7350;
  font-size: 0.9rem;
}
