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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fdf6e3;
  font-family: 'Caveat', cursive;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Notebook paper background */
  background-color: #fdf6e3;
  background-image:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      #c8dae8 31px,
      #c8dae8 32px
    );
  background-size: 100% 32px;
}

canvas#gameCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(253, 246, 227, 0.85);
  backdrop-filter: blur(3px);
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  max-width: 360px;
  width: 90%;
}

.title {
  font-size: 3.5rem;
  color: #1a3a5c;
  text-shadow: 2px 2px 0 #a3c4e6;
  margin-bottom: 0.3rem;
  line-height: 1;
}

.gameover-title {
  color: #c0392b;
  text-shadow: 2px 2px 0 #f5b7b1;
}

.subtitle {
  font-size: 1.6rem;
  color: #2e7d32;
  margin-bottom: 1.2rem;
}

.final-score {
  font-size: 4rem;
  font-weight: 700;
  color: #1a3a5c;
  margin: 0.5rem 0;
}

.high-score-line {
  font-size: 1.3rem;
  color: #888;
  margin-bottom: 1rem;
}

.new-record {
  font-size: 1.8rem;
  color: #e67e22;
  animation: bounce 0.6s ease infinite alternate;
  margin-bottom: 0.5rem;
}

@keyframes bounce {
  from { transform: scale(1); }
  to   { transform: scale(1.15); }
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.8rem 2.5rem;
  font-family: 'Caveat', cursive;
  font-size: 1.8rem;
  font-weight: 700;
  border: 3px solid #1a3a5c;
  border-radius: 14px;
  background: #e8f5e9;
  color: #1a3a5c;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 3px 3px 0 #1a3a5c;
}

.btn:hover {
  background: #c8e6c9;
  transform: translateY(-2px);
  box-shadow: 4px 5px 0 #1a3a5c;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 #1a3a5c;
}

.play-btn {
  background: #bbdefb;
}

.play-btn:hover {
  background: #90caf9;
}

.controls-hint {
  margin-top: 1.2rem;
  font-size: 1.1rem;
  color: #888;
  line-height: 1.6;
}

/* ── HUD ── */
#hud {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  z-index: 5;
  pointer-events: none;
}

#score-display {
  font-size: 2.2rem;
  font-weight: 700;
  color: #1a3a5c;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.6);
}

#lives-display {
  font-size: 1.6rem;
}

.heart {
  color: #e74c3c;
  margin-left: 3px;
  transition: opacity 0.3s;
}

.heart.lost {
  opacity: 0.2;
}

/* ── Mobile ── */
@media (max-width: 500px) {
  .title { font-size: 2.6rem; }
  .final-score { font-size: 3rem; }
  .btn { font-size: 1.5rem; padding: 0.6rem 1.8rem; }
}
