/* Puffling — one-touch hill glider. Full-bleed canvas. */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #7ec8e3;
  font-family: "Baloo 2", "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: none;
  /* iOS paints a translucent blue-grey tap highlight over the WHOLE tapped element —
     on a full-screen canvas that reads as a blue wash over the entire game. Kill it. */
  -webkit-tap-highlight-color: transparent;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* crash / fever flash */
.flash {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, rgba(255, 230, 150, 0.5), rgba(255, 200, 90, 0) 70%);
  opacity: 0; transition: opacity 140ms ease-out;
}
.flash.is-on { opacity: 1; transition: none; }
.confetti { position: fixed; inset: 0; z-index: 7; pointer-events: none; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0; right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
}
.hud__score {
  font-size: clamp(2rem, 8vw, 3.6rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fffaf0;
  text-shadow: 0 2px 0 rgba(120, 70, 40, 0.35), 0 5px 14px rgba(90, 50, 20, 0.35);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hud__best {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 250, 240, 0.85);
  text-shadow: 0 1px 3px rgba(90, 50, 20, 0.4);
  font-variant-numeric: tabular-nums;
}

.sound-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 6;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 140ms ease, background 140ms ease;
}
.sound-btn:hover { background: rgba(255, 255, 255, 0.42); }
.sound-btn[aria-pressed="false"] { color: rgba(255, 255, 255, 0.4); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(60, 90, 130, 0.72), rgba(30, 46, 74, 0.92));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity 260ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }

.panel-wrap { position: relative; }
.panel-bird {
  position: absolute;
  top: -150px;
  left: -26px;
  width: 200px;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 8px 22px rgba(20, 30, 50, 0.35));
  animation: birdpeek 520ms 160ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes birdpeek {
  from { transform: rotate(-12deg) translateY(34px); opacity: 0; }
  to { transform: rotate(-12deg) translateY(0); opacity: 1; }
}
@media (max-width: 560px) {
  .panel-bird { width: 148px; top: -112px; left: -10px; }
}
.panel {
  text-align: center;
  max-width: min(470px, calc(100vw - 28px));
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: min(34px, 4vh) min(30px, 5vw) min(32px, 3.8vh);
  border-radius: 26px;
  background: rgba(255, 252, 245, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 30px 80px -18px rgba(20, 30, 50, 0.6);
  animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 6px;
  font-size: min(clamp(2.4rem, 10vw, 4rem), 8.5vh);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 0.95;
  padding-bottom: 0.16em;
  background: linear-gradient(176deg, #ff9e5e 0%, #f2607a 55%, #c86fa8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 10px rgba(242, 96, 122, 0.35));
}
.panel__text { margin: 0 0 min(26px, 3vh); font-size: min(clamp(0.98rem, 3.4vw, 1.08rem), 3.6vh); line-height: 1.5; font-weight: 500; color: #5b4a3f; }
.panel__text b { color: #e0603f; font-weight: 800; }
.panel__text .stat { color: #e0603f; font-weight: 800; }
.play-btn {
  appearance: none;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ffb057, #ff8a3c);
  border: 0;
  padding: min(16px, 2.2vh) 42px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 26px -6px rgba(255, 138, 60, 0.7);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -8px rgba(255, 138, 60, 0.85); }
.play-btn:active { transform: translateY(0); }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(70, 60, 40, 0.45);
}
.frame__corner--tl { top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner--tr { top: max(14px, env(safe-area-inset-top)); right: max(62px, calc(env(safe-area-inset-right) + 48px)); }
.frame__corner--bl { bottom: max(14px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #fff; }

.hint {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(70, 60, 40, 0.45);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 300ms ease;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 560px) {
  .frame__corner--bl { display: none; }
  .frame__corner--tr { display: none; }
}

/* landscape phones / short viewports: compact card so everything fits without scrolling
   (kept at the end of the file so it wins the equal-specificity cascade) */
@media (max-height: 520px) {
  .overlay { padding: 10px; }
  .panel { max-width: 620px; padding: 14px 22px 16px; }
  .panel__title { font-size: clamp(1.6rem, 7vh, 2.1rem); margin-bottom: 2px; }
  .panel__text { font-size: 0.84rem; line-height: 1.42; margin-bottom: 12px; }
  .play-btn { padding: 10px 28px; font-size: 0.95rem; }
  .panel .opt-share { margin-top: 8px; padding: 7px 13px; }
  .panel-bird { width: 92px; top: -64px; left: -10px; }
}
