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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1418;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1418;
}

#game {
  display: block;
  background: #c7eaf5;
  touch-action: none;
}

/* HUD overlays positioned in JS to match the canvas's CSS bounds. */
#hud-score,
#drop-hint,
#game-over,
#level-complete,
#settings-panel,
#settings-btn {
  position: absolute;
  color: #1a2c3a;
  text-align: center;
  font-weight: 600;
}

#hud-score,
#drop-hint {
  pointer-events: none;
}

#hud-score {
  top: 0;
  font-size: clamp(24px, 5vmin, 56px);
  padding: 0.6em 0.8em;
  text-shadow: 0 2px 6px rgba(255, 255, 255, 0.6);
}

#drop-hint {
  font-size: clamp(18px, 3.4vmin, 38px);
  color: #2e4860;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7);
  line-height: 1.25;
  transition: opacity 0.4s;
}

#drop-hint.fade { opacity: 0; }

#settings-btn {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  font-size: clamp(22px, 4.5vmin, 42px);
  width: 2em;
  height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #2e4860;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 5;
  line-height: 1;
}

#settings-btn:active { transform: scale(0.92); }

/* Modal panels share styling. They appear over the canvas; pointer events
   on the dimmed backdrop fall through unless the panel itself catches them. */
#game-over,
#level-complete,
#settings-panel {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  padding: 2em 1.6em;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1em;
  align-items: stretch;
  justify-content: center;
  z-index: 10;
  pointer-events: auto;
}

#game-over[hidden],
#level-complete[hidden],
#settings-panel[hidden] { display: none; }

#game-over h1,
#level-complete h1 {
  font-size: clamp(36px, 9vmin, 90px);
  font-weight: 700;
  color: #16242f;
  text-align: center;
}

#settings-panel h2 {
  font-size: clamp(28px, 6vmin, 56px);
  font-weight: 700;
  color: #16242f;
  text-align: center;
  margin-bottom: 0.2em;
}

#final-score,
#level-complete-score {
  font-size: clamp(24px, 5vmin, 56px);
  color: #1a2c3a;
  text-align: center;
}

#game-over p {
  font-size: clamp(16px, 3vmin, 36px);
  color: #4a6175;
  font-weight: 500;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: clamp(18px, 3.6vmin, 38px);
  gap: 1em;
}

.settings-row label,
.settings-row .settings-label {
  color: #4a6175;
  font-weight: 500;
}

#level-select {
  font-size: inherit;
  font-family: inherit;
  font-weight: 600;
  color: #16242f;
  background: #ffffff;
  border: 2px solid #b8cad8;
  border-radius: 10px;
  padding: 0.3em 0.6em;
  min-width: 50%;
}

#settings-best {
  font-weight: 700;
  color: #16242f;
}

.panel-buttons {
  display: flex;
  gap: 0.8em;
  justify-content: center;
  margin-top: 0.4em;
  flex-wrap: wrap;
}

.panel-buttons button {
  flex: 1 1 40%;
  font-size: clamp(18px, 3.6vmin, 38px);
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 0.6em 1em;
  cursor: pointer;
  background: #2e4860;
  color: #ffffff;
  min-width: 7em;
}

.panel-buttons button:active { transform: scale(0.97); }

.panel-buttons button.secondary {
  background: #d3dee7;
  color: #2e4860;
}
