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

html {
  background: #10162f;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-x: hidden;
  color: #e8e8e8;
  background:
    radial-gradient(circle at top, #253761 0, #10162f 65%),
    #10162f;
  font-family: "Courier New", Courier, monospace;
}

button {
  font: inherit;
}

.game-wrapper {
  width: min(100%, 820px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hud {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 14px;
  background: #16213e;
  border: 3px solid #315b93;
  border-radius: 8px;
  box-shadow: 0 5px 0 #0a2647;
}

.hud-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.hud-label {
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#score,
#coins,
#lives,
#status {
  overflow: hidden;
  color: #fbbf24;
  font-size: clamp(14px, 3vw, 20px);
  font-weight: bold;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status {
  color: #86efac;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 4px solid #315b93;
  border-radius: 8px;
  box-shadow: 0 7px 0 #0a2647;
  background: #87ceeb;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 20, 0.76);
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-box {
  width: min(100%, 430px);
  padding: 28px 32px;
  text-align: center;
  background: #16213e;
  border: 4px solid #315b93;
  border-radius: 8px;
  box-shadow: 0 8px 0 #0a2647;
}

.overlay-box h2 {
  margin-bottom: 12px;
  color: #fbbf24;
  font-size: clamp(22px, 5vw, 30px);
}

.overlay-box p {
  margin-bottom: 20px;
  color: #cbd5e1;
  line-height: 1.5;
}

#restart-btn {
  padding: 12px 28px;
  color: #102119;
  background: #4ade80;
  border: 3px solid #166534;
  border-radius: 5px;
  box-shadow: 0 4px 0 #14532d;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#restart-btn:hover,
#restart-btn:focus-visible {
  background: #86efac;
  outline: 3px solid #fef08a;
  outline-offset: 3px;
}

#restart-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #14532d;
}

.touch-controls {
  width: 100%;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  user-select: none;
}

.touch-group {
  display: flex;
  gap: 12px;
}

.touch-button {
  width: 64px;
  height: 56px;
  color: #fff;
  background: #27496f;
  border: 2px solid #6ea8df;
  border-radius: 12px;
  box-shadow: 0 4px 0 #102f4d;
  touch-action: none;
  font-size: 26px;
  font-weight: bold;
}

.touch-button:active {
  transform: translateY(3px);
  background: #3b6f9f;
  box-shadow: 0 1px 0 #102f4d;
}

.jump-button {
  color: #102119;
  background: #4ade80;
  border-color: #bbf7d0;
  box-shadow: 0 4px 0 #166534;
}

.controls-hint {
  color: #aab8cf;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 560px) {
  body {
    align-items: flex-start;
    padding: 8px;
  }

  .game-wrapper {
    gap: 9px;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 10px;
  }

  .hud-status {
    display: none;
  }

  .overlay-box {
    padding: 20px 16px;
  }

  .controls-hint {
    font-size: 10px;
  }
}
