/* Banana Berry Jump — Mignuti Kids
 * Shared Banana Berry palette with Flappy Berry.
 */

:root {
  --color-cream: #fff8e7;
  --color-sky: #4ecdc4;
  --color-banana: #ffd93d;
  --color-berry: #de1c56;
  --color-ink: #2c2c2c;
  --color-leaf: #4aa84f;
  --color-strawberry: #e94f6b;
  --radius: 18px;
  --shadow-card: 0 8px 24px rgba(44, 44, 44, 0.18);
}

* {
  box-sizing: border-box;
}

/* Screen-reader-only helper — visually hidden but reachable by AT. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-cream);
  color: var(--color-ink);
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  overflow: hidden;
}

.stage {
  position: fixed;
  inset: 0;
  display: block;
  /* Biome colours are set via JS as --biome-top / --biome-bottom.
   * The 200ms transition softly fades the sky between palettes. */
  --biome-top: #bfefeb;
  --biome-bottom: #fff8e7;
  --biome-accent: #2f7b33;
  background: linear-gradient(
    180deg,
    var(--biome-top) 0%,
    var(--biome-bottom) 80%
  );
  transition: background 200ms linear;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: transparent;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.score {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 4px 0 var(--color-berry),
    0 6px 12px rgba(0, 0, 0, 0.22);
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
}

.controls {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn:focus-visible {
  outline: 3px solid var(--color-berry);
  outline-offset: 3px;
}

.icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  background: var(--color-ink);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.icon-sound-off {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm13.59 2L14 9.41 15.41 8 18 10.59 20.59 8 22 9.41 19.41 12 22 14.59 20.59 16 18 13.41 15.41 16 14 14.59 16.59 12z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm13.59 2L14 9.41 15.41 8 18 10.59 20.59 8 22 9.41 19.41 12 22 14.59 20.59 16 18 13.41 15.41 16 14 14.59 16.59 12z'/></svg>");
}

.icon-sound-on {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm11 0.5A3.5 3.5 0 0 1 17.5 14a3.5 3.5 0 0 1-3.5 3.5v-7zm0-4.5a8 8 0 0 1 8 8 8 8 0 0 1-8 8v-2a6 6 0 0 0 6-6 6 6 0 0 0-6-6V6z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm11 0.5A3.5 3.5 0 0 1 17.5 14a3.5 3.5 0 0 1-3.5 3.5v-7zm0-4.5a8 8 0 0 1 8 8 8 8 0 0 1-8 8v-2a6 6 0 0 0 6-6 6 6 0 0 0-6-6V6z'/></svg>");
}

.icon-pause {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M6 5h4v14H6zM14 5h4v14h-4z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M6 5h4v14H6zM14 5h4v14h-4z'/></svg>");
}

/* Invisible touch zones split the lower 70% into left/right halves.
 * Above them the top 30% is free so buttons & HUD stay tappable. */
.touch-zone {
  position: absolute;
  top: 30%;
  bottom: 0;
  width: 50%;
  background: transparent;
  border: none;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.touch-zone--left {
  left: 0;
}
.touch-zone--right {
  right: 0;
}
.touch-zone:focus-visible {
  outline: none;
  background: rgba(255, 217, 61, 0.15);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(44, 44, 44, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 20px;
  pointer-events: auto;
  animation: fadeIn 180ms ease both;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: var(--color-cream);
  border: 4px solid var(--color-banana);
  border-radius: 28px;
  padding: clamp(20px, 5vw, 36px) clamp(22px, 6vw, 42px);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.overlay-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 6.5vw, 40px);
  color: var(--color-berry);
  font-weight: 900;
  letter-spacing: 0.01em;
}

.overlay-sub {
  margin: 0 0 18px;
  font-size: clamp(16px, 3.6vw, 20px);
  color: var(--color-ink);
  line-height: 1.4;
}

.big-btn {
  display: inline-block;
  min-width: 200px;
  min-height: 56px;
  padding: 14px 28px;
  border: none;
  border-radius: 999px;
  background: var(--color-berry);
  color: #fff;
  font-weight: 800;
  font-size: clamp(18px, 4vw, 22px);
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 0 #9a1540;
  transition:
    transform 100ms ease,
    box-shadow 100ms ease;
}

.big-btn:hover {
  transform: translateY(-1px);
}

.big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #9a1540;
}

.big-btn:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 4px;
}

.overlay-hint {
  margin: 14px 0 0;
  font-size: 14px;
  opacity: 0.7;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Milestone banner: appears briefly on 10m / 25m / 50m / 100m / 200m.
 * Positioned below the score, non-blocking. */
.milestone {
  position: absolute;
  top: calc(max(18px, env(safe-area-inset-top)) + 56px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px) scale(0.92);
  background: var(--color-banana);
  color: var(--color-ink);
  font-weight: 900;
  font-size: clamp(20px, 5vw, 28px);
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(44, 44, 44, 0.25);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
  white-space: nowrap;
  border: 3px solid #fff;
}

.milestone.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Difficulty picker on the start screen. */
.mode-toggle {
  border: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-toggle__opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--color-banana);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  min-height: 40px;
  color: var(--color-ink);
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease;
}

.mode-toggle__opt input {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-berry);
  border-radius: 50%;
  margin: 0;
  display: inline-block;
  position: relative;
  cursor: pointer;
  background: #fff;
}

.mode-toggle__opt input:checked {
  background: var(--color-berry);
  box-shadow: inset 0 0 0 2px #fff;
}

.mode-toggle__opt:has(input:checked) {
  background: var(--color-berry);
  color: #fff;
  border-color: var(--color-berry);
}

.mode-toggle__opt:focus-within {
  outline: 3px solid var(--color-banana);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .overlay {
    animation: none;
  }
  .big-btn {
    transition: none;
  }
  .stage {
    transition: none;
  }
  .milestone {
    transition: opacity 100ms linear;
  }
  .mode-toggle__opt {
    transition: none;
  }
}
