:root {
  color-scheme: light;
  --ink: #173047;
  --muted: #5b6f81;
  --sky: #8ed9ff;
  --sun: #ffd86f;
  --mint: #78e3ad;
  --rose: #ff7ea6;
  --plum: #7251d8;
  --road: #586273;
  --card: rgba(255, 255, 255, 0.86);
  --shadow: 0 18px 50px rgba(22, 48, 71, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  align-items: center;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 216, 111, 0.92) 0 120px, transparent 121px),
    linear-gradient(135deg, #65c8ff 0%, #a7ecff 47%, #ffe69a 100%);
  color: var(--ink);
  display: flex;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  display: grid;
  gap: 14px;
  max-width: 1120px;
  width: min(100%, 1120px);
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.eyebrow {
  color: #244f6c;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 2px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 4rem);
  line-height: 0.94;
  margin: 0;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.hud-tile,
.hearts {
  align-items: center;
  background: var(--card);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(23, 48, 71, 0.12);
  display: grid;
  min-height: 56px;
  min-width: 82px;
  padding: 7px 11px;
}

.hud-tile span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-tile strong,
.hearts {
  font-size: 1.35rem;
  font-weight: 950;
}

.stage-wrap {
  aspect-ratio: 16 / 9;
  background: #79d7ff;
  border: 5px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  width: 100%;
}

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

.overlay {
  align-items: center;
  background: rgba(36, 79, 108, 0.18);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: absolute;
  transition: opacity 160ms ease, visibility 160ms ease;
}

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

.overlay-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(23, 48, 71, 0.26);
  max-width: 430px;
  padding: 24px;
  text-align: center;
}

.overlay-panel h2 {
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 0.94;
  margin: 0 0 9px;
}

.overlay-panel p {
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 18px;
}

.primary {
  background: #173047;
  border-radius: 8px;
  box-shadow: 0 9px 0 #0b1e31;
  color: white;
  font-size: 1.05rem;
  font-weight: 950;
  min-height: 52px;
  padding: 13px 22px 12px;
}

.primary:active {
  box-shadow: 0 3px 0 #0b1e31;
  transform: translateY(6px);
}

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.control-btn {
  align-items: center;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  box-shadow: 0 8px 0 rgba(23, 48, 71, 0.26);
  color: #142a3e;
  display: flex;
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  font-weight: 950;
  gap: 10px;
  justify-content: center;
  min-height: 72px;
  padding: 10px;
  touch-action: manipulation;
}

.control-btn:active,
.control-btn.active {
  box-shadow: 0 3px 0 rgba(23, 48, 71, 0.26);
  transform: translateY(5px);
}

.control-icon {
  align-items: center;
  background: rgba(255, 255, 255, 0.48);
  border-radius: 7px;
  display: inline-flex;
  font-size: 0.82rem;
  height: 38px;
  justify-content: center;
  min-width: 56px;
  padding: 0 8px;
}

.jump {
  background: var(--mint);
}

.duck {
  background: #ffc34f;
}

.freeze {
  background: #8bc8ff;
}

@media (max-width: 680px) {
  body {
    align-items: start;
    min-height: 100vh;
    overflow: auto;
    padding: 10px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .hud {
    justify-content: stretch;
    width: 100%;
  }

  .hud-tile,
  .hearts {
    flex: 1;
    min-width: 0;
  }

  .stage-wrap {
    border-width: 3px;
  }

  .controls {
    bottom: 10px;
    left: 10px;
    position: sticky;
    right: 10px;
  }

  .control-btn {
    flex-direction: column;
    gap: 4px;
    min-height: 76px;
  }
}
