:root {
  color-scheme: light;
  --ink: #263047;
  --leaf: #44b86a;
  --grass: #8bdd7e;
  --sky: #88ddff;
  --sun: #ffe06d;
  --path: #efc98d;
  --rose: #ff759c;
  --blue: #3f8fe8;
  --shadow: rgba(38, 48, 71, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 13%, rgba(255, 224, 109, 0.94) 0 86px, transparent 88px),
    linear-gradient(180deg, #77d9ff 0%, #c7f5ff 48%, #a7eb8f 49%, #69cc68 100%);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
}

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

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100vw, 1240px);
  height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 20px);
  gap: clamp(10px, 1.8vw, 16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #316437;
  font-size: clamp(0.78rem, 1.6vw, 0.92rem);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4.8vw, 4rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.58);
}

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

.hud-tile {
  min-width: 86px;
  padding: 8px 10px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 20px var(--shadow);
  text-align: center;
}

.hud-tile span,
.hud-tile strong {
  display: block;
}

.hud-tile span {
  color: #526333;
  font-size: clamp(0.7rem, 1.4vw, 0.82rem);
  font-weight: 900;
  text-transform: uppercase;
}

.hud-tile strong {
  font-size: clamp(1.1rem, 2.1vw, 1.42rem);
  line-height: 1;
}

.stage-wrap {
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: var(--sky);
  box-shadow: 0 18px 42px var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(54, 111, 148, 0.16);
  backdrop-filter: blur(2px);
  transition: opacity 160ms ease, visibility 160ms ease;
}

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

.overlay-panel {
  width: min(520px, 92vw);
  padding: clamp(20px, 4vw, 30px);
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 44px rgba(38, 48, 71, 0.28);
  text-align: center;
}

.badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff09b;
  color: #746126;
  font-weight: 950;
}

h2 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 3.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.overlay-panel p:last-of-type {
  max-width: 30rem;
  margin: 12px auto 18px;
  color: #535f3a;
  font-size: clamp(1rem, 2.8vw, 1.16rem);
  font-weight: 800;
  line-height: 1.35;
}

.primary,
.control-btn {
  min-height: 58px;
  border-radius: 8px;
  color: white;
  font-weight: 1000;
  box-shadow: 0 8px 0 #1d6e3b, 0 14px 22px var(--shadow);
}

.primary {
  padding: 0 24px;
  background: linear-gradient(180deg, #66d57e, #269554);
  font-size: clamp(1.05rem, 3vw, 1.35rem);
}

.controls {
  display: grid;
  grid-template-columns: minmax(130px, 230px) minmax(140px, 230px);
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 76px;
}

.control-btn {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  background: linear-gradient(180deg, #4d9df5, #2f65c8);
  box-shadow: 0 8px 0 #24448d, 0 14px 22px var(--shadow);
  font-size: clamp(1rem, 2.4vw, 1.24rem);
}

.control-btn.restart {
  background: linear-gradient(180deg, #ff8c62, #db5148);
  box-shadow: 0 8px 0 #8c332d, 0 14px 22px var(--shadow);
}

.control-icon {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.24);
  font-size: 1.25rem;
}

.primary:active,
.control-btn:active,
.control-btn.active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 rgba(38, 48, 71, 0.42), 0 9px 18px var(--shadow);
}

.primary:focus-visible,
.control-btn:focus-visible {
  outline: 4px solid #fff09b;
  outline-offset: 4px;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100svh;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .hud {
    max-width: 100%;
    justify-content: flex-start;
  }

  .stage-wrap {
    aspect-ratio: 16 / 10;
  }

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

@media (max-width: 460px) {
  .hud-tile {
    min-width: 74px;
    padding-inline: 8px;
  }

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