:root {
  --ink: #293A94;
  --cream: #F8FAF2;
  --mint: #A7E8BD;
  --pink: #FFCEF0;
  --orange: #FF8A3D;
  --shadow: rgba(41, 58, 148, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 206, 240, 0.9), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(167, 232, 189, 0.85), transparent 30%),
    linear-gradient(135deg, #F8FAF2, #D0E3FF 55%, #FFF3BA);
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-shell {
  width: min(1040px, 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  font-weight: 800;
}

.back-link {
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid rgba(41, 58, 148, 0.22);
  border-radius: 999px;
  padding: 9px 16px;
  box-shadow: 0 8px 18px var(--shadow);
}

.scoreboard {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scoreboard span {
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(41, 58, 148, 0.16);
  border-radius: 999px;
  padding: 9px 14px;
  box-shadow: 0 8px 18px var(--shadow);
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 4px solid rgba(41, 58, 148, 0.4);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 24px 55px rgba(41, 58, 148, 0.2);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #F8FAF2;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(248, 250, 242, 0.82);
}

.overlay.is-hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.6rem);
  line-height: 0.95;
}

.overlay p {
  max-width: 520px;
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  color: white;
  background: linear-gradient(135deg, var(--ink), #596BDB);
  border-radius: 999px;
  padding: 12px 28px;
  box-shadow: 0 12px 22px rgba(41, 58, 148, 0.28);
}

button:active {
  transform: translateY(2px);
}

.mobile-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.mobile-controls button:first-child {
  background: linear-gradient(135deg, #00A364, #25C985);
}

.mobile-controls button:last-child {
  background: linear-gradient(135deg, var(--orange), #FF5F62);
}

@media (max-width: 760px) {
  body {
    padding: 10px;
    align-items: start;
  }

  .game-shell {
    width: 100%;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

  .back-link,
  .scoreboard span {
    padding: 8px 12px;
  }

  .back-link {
    text-align: center;
  }

  .scoreboard {
    justify-content: space-between;
    gap: 8px;
    font-size: 0.95rem;
  }

  .scoreboard span {
    flex: 1;
    text-align: center;
  }

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

  .overlay {
    padding: 18px;
    gap: 12px;
  }

  .overlay h1 {
    font-size: clamp(2.2rem, 12vw, 4rem);
  }

  .overlay p {
    max-width: 310px;
    font-size: 1rem;
    line-height: 1.25;
  }

  .mobile-controls {
    display: grid;
    position: sticky;
    bottom: 10px;
  }

  .mobile-controls button {
    min-height: 64px;
    font-size: 1.2rem;
    border-radius: 22px;
  }
}
