* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: rgba(12, 22, 34, 0.9);
  --panel-2: rgba(19, 31, 43, 0.94);
  --line: rgba(255, 255, 255, 0.15);
  --text: #f8fafc;
  --muted: #b6c3d1;
  --track: #35c4a5;
  --gold: #ffd166;
  --coral: #ff7a59;
}
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(53, 196, 165, 0.16), transparent 32%),
    linear-gradient(230deg, rgba(255, 122, 89, 0.16), transparent 36%),
    linear-gradient(160deg, #111827 0%, #18283a 48%, #24312c 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
  border: 0;
  cursor: pointer;
  color: #08111c;
  font-weight: 850;
  transition: transform 140ms ease, opacity 140ms ease, filter 140ms ease;
}
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { cursor: not-allowed; opacity: 0.48; filter: grayscale(0.45); }
.wrap {
  width: min(1040px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 22px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 8px 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}
h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.25rem); letter-spacing: 0; }
p { margin: 0; }
.top p { margin-top: 4px; color: var(--muted); font-size: 0.95rem; }
#restartBtn {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #fb923c);
}
.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.pill span { color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.pill strong { font-size: 1.12rem; color: #fff; white-space: nowrap; }
.stage-shell {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: #07131d;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
#game-stage {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 72vh;
  min-height: 420px;
}
#game-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 0.5fr)) minmax(250px, 1fr);
  gap: 10px 12px;
  align-items: center;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 14px 14px;
  background: var(--panel);
}
#upperBtn, #lowerBtn, #sprintBtn, #rewardBtn {
  min-height: 50px;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 0.94rem;
}
#upperBtn, #lowerBtn { background: linear-gradient(135deg, #e8f5ff, #92e6ff); }
#sprintBtn { background: linear-gradient(135deg, var(--track), #b7f56a); }
#rewardBtn { background: linear-gradient(135deg, var(--gold), var(--coral)); }
#statusText {
  color: #e2e8f0;
  font-weight: 800;
  min-height: 24px;
}
#rewardNote {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
@media (max-width: 840px) {
  .wrap { width: min(100vw - 16px, 620px); padding-top: 8px; }
  .top { align-items: flex-start; padding: 13px; }
  #restartBtn { min-height: 38px; padding: 0 13px; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pill { min-height: 46px; }
  #game-stage { min-height: 360px; max-height: 68vh; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  #statusText, #rewardNote { grid-column: 1 / -1; }
}
