/* Flappy Berry — Mignuti Kids
 * Palette aligns with the Banana Berry brand tokens used on mignuti-kids.com
 *   cream       #fff8e7
 *   sky         #4ecdc4
 *   banana      #ffd93d
 *   berry-pink  #de1c56 (a11y-safe)
 *   ink         #2c2c2c
 */

:root {
  --color-cream: #fff8e7;
  --color-sky: #4ecdc4;
  --color-banana: #ffd93d;
  --color-berry: #de1c56;
  --color-ink: #2c2c2c;
  --color-leaf: #4aa84f;
  --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 fills the iframe viewport */
.stage {
  position: fixed;
  inset: 0;
  display: block;
  background: linear-gradient(
    180deg,
    var(--color-cream) 0%,
    var(--color-cream) 45%,
    #bfefeb 100%
  );
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* prevent scroll/zoom interfering with taps */
  background: transparent;
}

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

.score {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) scale(1);
  transform-origin: center top;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 4px 0 var(--color-berry),
    0 6px 12px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.02em;
  line-height: 1;
  transition: transform 220ms ease-out;
}

.score.is-pulse {
  animation: score-pulse 600ms ease-out 1;
}

@keyframes score-pulse {
  0% {
    transform: translateX(-50%) scale(1);
  }
  40% {
    transform: translateX(-50%) scale(1.28);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

.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>");
}

/* 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(28px, 7vw, 44px);
  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;
}

/* Animated start-screen arrow — gently bobs to cue a first tap. */
.start-hint-anim {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--color-berry);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.start-arrow {
  display: inline-block;
  font-size: 28px;
  line-height: 1;
  animation: start-bob 900ms ease-in-out infinite alternate;
}

.start-label {
  animation: start-bob 900ms ease-in-out infinite alternate;
  animation-delay: 80ms;
}

@keyframes start-bob {
  from {
    transform: translateY(-4px);
    opacity: 0.85;
  }
  to {
    transform: translateY(4px);
    opacity: 1;
  }
}

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

/* Reduced motion: disable overlay fade-in */
@media (prefers-reduced-motion: reduce) {
  .overlay {
    animation: none;
  }
  .big-btn {
    transition: none;
  }
  .start-arrow,
  .start-label {
    animation: none;
  }
  .score.is-pulse {
    animation: none;
  }
  .score {
    transition: none;
  }
}
