:root {
  color-scheme: dark;
  --ink: #241735;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(77, 48, 126, 0.28);
  --text: #2b2147;
  --accent: #ff6fae;
  --accent-dark: #7a3ea8;
  --button: #fff7fb;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 246, 178, 0.58), transparent 24rem),
    linear-gradient(180deg, #9e7cff 0%, #f48bc8 52%, #5b3e84 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  appearance: none;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(83, 51, 122, 0.22);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

button:hover {
  background: #ffffff;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(83, 51, 122, 0.22);
}

.game-shell {
  width: min(1120px, calc(100vw - 28px), calc((100vh - 148px) * 16 / 9));
  display: grid;
  gap: 12px;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 80px rgba(34, 21, 68, 0.26);
}

.hud div {
  display: grid;
  gap: 2px;
  min-width: 92px;
}

.hud div:last-child {
  text-align: right;
}

.label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  color: rgba(43, 33, 71, 0.66);
}

.hud strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1;
}

.stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: #211739;
  box-shadow:
    0 28px 90px rgba(34, 21, 68, 0.38),
    inset 0 0 0 1px rgba(82, 54, 130, 0.18);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(43, 27, 68, 0.1), rgba(43, 27, 68, 0.36));
}

.overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay h1 {
  margin: 0;
  color: #fff8ff;
  font-size: clamp(2.5rem, 9vw, 6.8rem);
  line-height: 0.9;
  text-shadow:
    0 4px 0 #6b3f9b,
    0 12px 28px rgba(58, 28, 88, 0.35);
}

.overlay p {
  max-width: min(520px, 100%);
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel-strong);
  font-weight: 800;
  line-height: 1.3;
}

.overlay button {
  min-width: 148px;
  padding: 0 20px;
  background: linear-gradient(180deg, #fff 0%, #ffe0ed 100%);
  color: var(--accent-dark);
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.controls button {
  padding: 0 16px;
}

#jumpButton {
  background: linear-gradient(180deg, #fff 0%, #ffd7eb 100%);
  color: #6f2c87;
}

@media (max-width: 680px) {
  body {
    align-items: start;
    padding-top: max(8px, env(safe-area-inset-top));
    overflow: auto;
  }

  .game-shell {
    width: min(100vw - 16px, 760px);
  }

  .hud {
    padding: 8px 10px;
  }

  .controls {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .controls button {
    min-width: 0;
    padding: 0 8px;
    font-size: 0.92rem;
  }
}
