:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08090d;
  color: #fff6d7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(63, 96, 118, 0.2), rgba(8, 9, 13, 0) 36%),
    linear-gradient(135deg, #08090d 0%, #12131a 52%, #0a1210 100%);
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  position: relative;
  width: min(100%, 1080px);
  aspect-ratio: 3 / 2;
  min-height: 420px;
  max-height: calc(100vh - 36px);
  border: 1px solid rgba(255, 238, 172, 0.28);
  border-radius: 8px;
  background: #05070b;
  box-shadow: 0 22px 90px rgba(0, 0, 0, 0.62), 0 0 0 8px rgba(255, 198, 71, 0.04);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  inset: 14px 14px auto 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud div {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid rgba(255, 246, 215, 0.17);
  border-radius: 6px;
  background: rgba(4, 7, 14, 0.76);
  backdrop-filter: blur(10px);
}

.label {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 246, 215, 0.6);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud strong {
  display: block;
  overflow: hidden;
  color: #ffe56c;
  font-size: clamp(0.92rem, 1.7vw, 1.24rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#lives {
  min-height: 22px;
}

.life-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 22px;
}

.life-rv {
  position: relative;
  display: inline-block;
  width: 31px;
  height: 17px;
  border: 1px solid #6b3a22;
  border-radius: 3px;
  background:
    linear-gradient(90deg, #fff7d4 0 26%, #f3d86e 26% 100%);
  box-shadow: inset 0 -4px 0 #2b86c7;
}

.life-rv::before {
  content: "";
  position: absolute;
  inset: 3px 4px auto auto;
  width: 8px;
  height: 6px;
  border-radius: 1px;
  background: #172e44;
  box-shadow: -11px 0 0 #b8ecff;
}

.life-rv::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: -4px;
  height: 6px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 3px 3px, #05070b 0 3px, transparent 3px),
    radial-gradient(circle at calc(100% - 3px) 3px, #05070b 0 3px, transparent 3px);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: min(8vw, 64px);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(3, 5, 10, 0.15), rgba(3, 5, 10, 0.9)),
    radial-gradient(circle at 50% 44%, rgba(255, 217, 95, 0.2), transparent 38%);
}

.overlay.hidden {
  display: none;
}

.intro-portrait {
  width: clamp(112px, 18vw, 176px);
  height: clamp(112px, 18vw, 176px);
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 0 #672424) drop-shadow(0 22px 28px rgba(0, 0, 0, 0.55));
}

h1 {
  margin: 0;
  color: #ffe56c;
  font-size: clamp(2.7rem, 8vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 8px 0 #672424, 0 24px 42px rgba(0, 0, 0, 0.8);
}

.overlay p {
  max-width: 650px;
  margin: 0;
  color: rgba(255, 246, 215, 0.88);
  font-size: clamp(0.98rem, 1.8vw, 1.16rem);
  line-height: 1.45;
}

#startButton {
  min-width: 150px;
  padding: 12px 18px;
  border-radius: 6px;
  color: #101217;
  background: #ffce45;
  box-shadow: 0 4px 0 #a54f27;
  cursor: pointer;
  font-weight: 850;
}

#startButton:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a54f27;
}

.keys {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  color: rgba(255, 246, 215, 0.74);
  font-size: 0.9rem;
}

kbd {
  min-width: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 246, 215, 0.24);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff6d7;
  font: 800 0.82rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.touch-controls {
  position: absolute;
  inset: auto 16px 16px 16px;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.touch-controls button {
  min-height: 52px;
  border: 1px solid rgba(255, 246, 215, 0.22);
  border-radius: 6px;
  color: #fff6d7;
  background: rgba(4, 7, 14, 0.76);
  backdrop-filter: blur(10px);
  font-size: 1.5rem;
  font-weight: 900;
}

@media (hover: none), (max-width: 720px) {
  body {
    padding: 0;
  }

  .game-shell {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .hud {
    inset: 9px 9px auto 9px;
    gap: 6px;
  }

  .hud div {
    padding: 7px 8px;
  }

  .touch-controls {
    display: grid;
  }
}
