/* Same palette and type as the homepage, so the game reads as the same site. */
:root {
  --bg-top: #172119;
  --bg-bottom: #0d120e;

  --card: rgba(30, 38, 31, 0.72);

  --text: #f2eadb;
  --muted: #b8b0a0;

  --accent: #9ed2a4;

  --border: rgba(255, 255, 255, 0.06);

  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --image-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;

  padding: clamp(10px, 2vw, 24px);

  overflow-x: hidden;

  background:
    radial-gradient(
      circle at top,
      rgba(65, 90, 70, 0.25),
      transparent 40%
    ),
    linear-gradient(
      to bottom,
      var(--bg-top),
      var(--bg-bottom)
    );

  color: var(--text);

  font-family: Georgia, "Times New Roman", serif;
}

.wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

/* ---------- header and hud ---------- */

.topbar {
  margin: 0 0 14px;
}

.title {
  margin: 0 0 10px;

  font-size: clamp(1.05rem, 2.6vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: center;

  font-size: 0.86rem;
  letter-spacing: 0.4px;

  color: var(--muted);
}

.stat b {
  color: var(--text);
  font-size: 1.02rem;

  /* Tabular figures stop the layout twitching as the score ticks up. */
  font-variant-numeric: tabular-nums;
}

.mute {
  font: inherit;
  font-size: 0.82rem;

  color: var(--muted);

  padding: 4px 12px;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;

  cursor: pointer;
}

.mute:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ---------- stage ---------- */

.stage {
  position: relative;

  width: 100%;
  aspect-ratio: 3 / 2;

  margin: 0 auto;

  overflow: hidden;

  border-radius: clamp(12px, 1.6vw, 18px);

  /* The jungle is painted by the browser once and never redrawn, so the
     canvas above it only has to carry the monkey and the balls. */
  background-image: url("../monkey.webp");
  background-size: cover;
  background-position: center;

  box-shadow: var(--image-shadow);
}

#canvas {
  display: block;

  width: 100%;
  height: 100%;

  /* Keep a drag on the jungle from scrolling or zooming the page. */
  touch-action: none;
}

/* ---------- level banner ---------- */

.banner {
  position: absolute;
  top: 16%;
  left: 50%;

  padding: 8px 22px;

  transform: translateX(-50%) scale(0.9);

  font-size: clamp(1rem, 3vw, 1.6rem);
  letter-spacing: 1px;

  color: var(--text);

  background: rgba(13, 18, 14, 0.6);
  border: 1px solid var(--border);
  border-radius: 999px;

  backdrop-filter: blur(4px);

  opacity: 0;
  pointer-events: none;
}

.banner.show {
  animation: bannerPop 1.5s ease-out forwards;
}

@keyframes bannerPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.85); }
  18% { opacity: 1; transform: translateX(-50%) scale(1); }
  72% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.04); }
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 18px;

  background: rgba(9, 13, 10, 0.62);

  backdrop-filter: blur(3px);
}

.overlay[hidden] {
  display: none;
}

.panel {
  max-width: 430px;

  padding: clamp(16px, 3vw, 26px);

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;

  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 10px;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
}

.panel-body {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.panel-keys {
  margin: 0 0 16px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.84rem;
  line-height: 1.6;
}

.btn {
  font: inherit;
  font-size: 0.98rem;

  color: #10180f;

  padding: 9px 26px;

  background: var(--accent);
  border: 0;
  border-radius: 999px;

  cursor: pointer;
}

.btn:hover {
  background: #b6e0bb;
}

/* ---------- footer ---------- */

.footnote {
  max-width: 560px;
  margin: 16px auto 0;

  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.back {
  margin: 18px 0 0;
  font-size: 0.86rem;
}

.back a {
  color: rgba(255, 255, 255, 0.42);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  padding-bottom: 1px;
}

.back a:hover {
  color: var(--text);
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

@media (max-width: 640px) {
  .footnote {
    font-size: 0.86rem;
  }

  .hud {
    gap: 6px 12px;
    font-size: 0.8rem;
  }
}
