@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@600;700;800&display=swap');

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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #5eb8f0 0%, #87ceeb 45%, #b8e8a0 100%);
  font-family: 'Nunito', sans-serif;
  color: #2a3a48;
}

#game-container {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #2a3a48,
    0 16px 48px rgba(42, 58, 72, 0.35);
  touch-action: none;
}

@media (max-width: 520px), (max-height: 800px) {
  body {
    padding: 0;
    align-items: stretch;
    background: #87ceeb;
  }

  #game-container {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  #game {
    height: 100dvh;
    width: min(100vw, calc(100dvh * 480 / 720));
    max-width: 100vw;
    display: block;
    margin: 0 auto;
  }
}

#game {
  display: block;
  outline: none;
}

#overlay,
#game-over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(135, 206, 235, 0.94);
  backdrop-filter: blur(8px);
  padding: 2rem 1.5rem;
  text-align: center;
  gap: 0.65rem;
  z-index: 10;
}

.logo {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
  -webkit-text-stroke: 2px #2a3a48;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 #2a3a48;
  line-height: 1.1;
}

.tagline {
  color: #2d5016;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

#overlay ul {
  list-style: none;
  text-align: left;
  color: #2a3a48;
  font-size: 0.88rem;
  line-height: 2;
  max-width: 340px;
}

.hint {
  color: #94a3b8;
  font-size: 0.78rem;
}

kbd {
  background: #ffffff;
  padding: 3px 9px;
  border-radius: 8px;
  border: 2px solid #2a3a48;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d5016;
}

button {
  margin-top: 1.2rem;
  padding: 15px 44px;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  border: 3px solid #2a3a48;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(180deg, #7aea74 0%, #5cd65c 100%);
  color: #2a3a48;
  box-shadow: 0 5px 0 #2a3a48;
  transition: transform 0.12s, box-shadow 0.12s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #2a3a48;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #2a3a48;
}

.hidden {
  display: none !important;
}

#game-over h2 {
  font-family: 'Fredoka', sans-serif;
  color: #dc2626;
  font-size: 1.8rem;
  -webkit-text-stroke: 1px #2a3a48;
}

#final-score {
  font-size: 1.15rem;
  color: #713f12;
  font-weight: 800;
}

#final-height,
#final-theme {
  color: #2a3a48;
  font-size: 0.92rem;
}

#mobile-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}

#mobile-controls.visible {
  display: flex;
}

.mob-move {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.mob-btn {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  border: 3px solid #2a3a48;
  border-radius: 16px;
  cursor: pointer;
  color: #2a3a48;
  box-shadow: 0 4px 0 #2a3a48;
  transition: transform 0.08s, box-shadow 0.08s, background 0.08s;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mob-btn:active,
.mob-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2a3a48;
}

.mob-jump {
  width: 80px;
  height: 80px;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
  background: linear-gradient(180deg, #fde047 0%, #facc15 100%);
}

.mob-jump .mob-icon,
.mob-jump .mob-label {
  display: none;
}

.mob-dir {
  width: 72px;
  height: 72px;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0;
  background: linear-gradient(180deg, #bae6fd 0%, #7dd3fc 100%);
}

@media (pointer: fine) and (min-width: 521px) {
  #mobile-controls {
    display: none !important;
  }
}

@media (pointer: coarse), (max-width: 520px) {
  #mobile-controls.visible {
    display: flex;
  }
}

.leaderboard-box {
  margin-top: 1rem;
  width: min(100%, 320px);
  text-align: left;
}

.leaderboard-box h3,
#game-over h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  color: #713f12;
  margin-bottom: 0.4rem;
}

#menu-leaderboard,
#game-leaderboard {
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.65);
  border: 2px solid #2a3a48;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

#menu-leaderboard li,
#game-leaderboard li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(42, 58, 72, 0.15);
}

#menu-leaderboard li:last-child,
#game-leaderboard li:last-child {
  border-bottom: none;
}

.lb-rank {
  color: #713f12;
  font-weight: 800;
  min-width: 1.4rem;
}

.lb-score {
  margin-left: auto;
  font-weight: 800;
  color: #2d5016;
}

.lb-meta {
  color: #64748b;
  font-size: 0.72rem;
}

.lb-empty {
  color: #64748b;
  font-style: italic;
}

.score-submit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 280px);
  margin: 0.6rem 0;
}

#player-name {
  padding: 10px 12px;
  border: 2px solid #2a3a48;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

#save-score-btn {
  margin-top: 0;
  padding: 12px 20px;
  font-size: 1rem;
  background: linear-gradient(180deg, #fde047 0%, #facc15 100%);
}

.save-status {
  font-size: 0.8rem;
  color: #2d5016;
  min-height: 1.1em;
  margin-top: 0.35rem;
}

.personal-best {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fef08a;
  text-shadow: 1px 1px 0 #000;
  margin: 0.5rem 0 0.75rem;
  min-height: 1.2em;
  white-space: pre-line;
}

#game-over {
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

#game-leaderboard {
  max-height: 120px;
  width: min(100%, 300px);
}
