:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #231f35;
  --muted: #6d657c;
  --panel: rgba(255, 255, 255, 0.84);
  --line: rgba(68, 47, 78, 0.18);
  --rose: #e94f7d;
  --gold: #f7b84b;
  --mint: #3fbf99;
  --sky: #86d6f6;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(134, 214, 246, 0.9), rgba(255, 222, 191, 0.78) 58%, #7fd38c),
    #b6ecff;
}

button {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: center;
  padding: 24px 0;
}

.game-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(50, 35, 62, 0.22);
}

.hud {
  height: 58px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px);
}

.hud div {
  min-width: 0;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  font-size: 1.25rem;
}

canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  image-rendering: pixelated;
  background: var(--sky);
}

.message {
  position: absolute;
  inset: 58px 0 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 249, 244, 0.18), rgba(255, 249, 244, 0.08));
  pointer-events: none;
}

.message button {
  pointer-events: auto;
}

body[data-game-state="title"] .message {
  align-content: center;
  background: transparent;
}

body[data-game-state="title"] .message h1,
body[data-game-state="title"] .message p {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body[data-game-state="title"] .message button {
  margin-top: 212px;
  border: 3px solid #fff7ed;
  background: #e11d48;
  box-shadow:
    0 8px 0 #9f1239,
    0 0 0 5px rgba(15, 23, 42, 0.45);
  text-transform: uppercase;
}

.message[hidden] {
  display: none;
}

.message h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.7rem);
  line-height: 0.95;
}

.message p {
  width: min(520px, 100%);
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.message button,
.touch-controls button {
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--rose);
  box-shadow: 0 8px 0 #b82f59;
  cursor: pointer;
}

.message button {
  justify-self: center;
  min-width: 150px;
  padding: 12px 18px;
  font-weight: 900;
}

.message button:active,
.touch-controls button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #b82f59;
}

.touch-controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: none;
  grid-template-columns: 58px 58px 1fr 64px;
  gap: 10px;
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

.touch-controls button {
  width: 58px;
  height: 52px;
  font-size: 1.4rem;
  font-weight: 900;
  pointer-events: auto;
}

.touch-controls button[data-key="jump"] {
  justify-self: end;
  width: 64px;
  background: var(--mint);
  box-shadow: 0 8px 0 #25896a;
}

.side-panel {
  border-left: 1px solid rgba(68, 47, 78, 0.2);
  padding: 8px 0 8px 22px;
}

.side-panel h2 {
  margin: 0 0 10px;
  font-size: 1.4rem;
}

.side-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.55;
}

.side-panel code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.52);
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  font-weight: 700;
}

@media (hover: none) and (pointer: coarse) {
  body[data-game-state="playing"] .touch-controls {
    display: grid;
  }
}

@media (max-width: 760px) {
  body[data-game-state="playing"] .touch-controls {
    display: grid;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid rgba(68, 47, 78, 0.2);
    padding: 16px 0 0;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 18px, 1180px);
    padding: 10px 0;
  }

  .hud {
    height: 52px;
    padding: 0 10px;
  }

  .hud strong {
    font-size: 1.05rem;
  }

  .message {
    inset: 52px 0 0;
    padding: 18px;
  }

  .message p {
    font-size: 0.95rem;
  }

  body[data-game-state="title"] .message button {
    margin-top: 152px;
  }

  .touch-controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: 42px 42px 1fr 48px;
    gap: 7px;
  }

  .touch-controls button {
    width: 42px;
    height: 38px;
    border-radius: 7px;
    font-size: 1.05rem;
    box-shadow: 0 5px 0 #b82f59;
  }

  .touch-controls button[data-key="jump"] {
    width: 48px;
    box-shadow: 0 5px 0 #25896a;
  }

  .touch-controls button:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #b82f59;
  }

  .touch-controls button[data-key="jump"]:active {
    box-shadow: 0 2px 0 #25896a;
  }
}

@media (max-width: 390px) {
  .shell {
    width: calc(100vw - 12px);
    padding: 6px 0;
  }

  .hud {
    height: 46px;
  }

  .label {
    font-size: 0.62rem;
  }

  .hud strong {
    font-size: 0.96rem;
  }

  .message {
    inset: 46px 0 0;
  }

  body[data-game-state="title"] .message button {
    margin-top: 136px;
    min-width: 136px;
    padding: 10px 14px;
  }

  .touch-controls {
    grid-template-columns: 38px 38px 1fr 44px;
    gap: 6px;
  }

  .touch-controls button {
    width: 38px;
    height: 34px;
    font-size: 0.95rem;
  }

  .touch-controls button[data-key="jump"] {
    width: 44px;
  }
}
