/* =====================================================================
   EL MONSTRUO DE LA BAÑERA · styles.css
   El juego se dibuja en un <canvas> a pantalla completa; el CSS solo
   se ocupa del lienzo, de los botones-burbuja y de pequeños avisos.
   ===================================================================== */

:root {
  --wall: #d9f5e8;
  --pink: #ff8fbd;
  --pink-deep: #e5679f;
  --ink: #6b2c52;
  --rim: 45dvh;                /* altura del borde de la bañera (la ajusta app.js) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --btn: clamp(48px, 7.5vmin, 64px);
  --btn-big: clamp(64px, 12vmin, 92px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--wall);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Baloo 2", "Fredoka", "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Botones-burbuja ---------- */

.bubble-btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: var(--btn);
  height: var(--btn);
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.98) 0 14%, rgba(255, 255, 255, 0.55) 15% 40%, rgba(190, 232, 255, 0.5) 100%);
  box-shadow:
    0 8px 18px rgba(86, 150, 200, 0.28),
    inset 0 -6px 12px rgba(120, 190, 240, 0.35),
    inset 0 4px 8px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  z-index: 5;
}

.bubble-btn svg {
  width: 62%;
  height: 62%;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(150, 70, 110, 0.18));
}

.bubble-btn:hover {
  transform: scale(1.06);
}

.bubble-btn:active,
.bubble-btn.pressed {
  transform: scale(0.88);
}

.bubble-btn:focus-visible {
  outline: 4px solid #ffd54a;
  outline-offset: 3px;
}

.hud-btn {
  top: calc(var(--safe-t) + 12px);
  opacity: 0.88;
}

.hud-sound {
  left: calc(var(--safe-l) + 12px);
}

.hud-full {
  left: calc(var(--safe-l) + 12px + var(--btn) + 12px);
}

.hud-btn[hidden] {
  display: none;
}

/* Icono de sonido silenciado / pantalla completa activa */
.hud-sound .slash {
  display: none;
}

.hud-sound.muted .waves {
  display: none;
}

.hud-sound.muted .slash {
  display: block;
}

.hud-full .icon-exit {
  display: none;
}

.hud-full.is-full .icon-enter {
  display: none;
}

.hud-full.is-full .icon-exit {
  display: block;
}

/* ---------- Botón del estornudo ---------- */

.sneeze-wrap {
  position: fixed;
  right: calc(var(--safe-r) + max(2.5vw, 14px));
  bottom: calc(var(--rim) + 14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 5;
  pointer-events: none;
}

.sneeze-btn {
  position: relative;
  width: var(--btn-big);
  height: var(--btn-big);
  pointer-events: auto;
}

.sneeze-btn svg {
  width: 72%;
  height: 72%;
}

.sneeze-btn.attract {
  animation: attractWiggle 5.5s ease-in-out infinite;
}

.sneeze-btn.attract::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  animation: attractRing 5.5s ease-out infinite;
  pointer-events: none;
}

.sneeze-btn.busy {
  opacity: 0.6;
  transform: scale(0.94);
}

.key-hint {
  display: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  padding: 1px 9px;
  border-radius: 99px;
}

@media (hover: hover) and (pointer: fine) {
  .key-hint {
    display: block;
  }
}

@keyframes attractWiggle {
  0%, 82%, 100% { transform: rotate(0) scale(1); }
  86% { transform: rotate(-10deg) scale(1.08); }
  90% { transform: rotate(9deg) scale(1.08); }
  94% { transform: rotate(-6deg) scale(1.04); }
  97% { transform: rotate(3deg) scale(1.02); }
}

@keyframes attractRing {
  0%, 82% { transform: scale(0.9); opacity: 0; }
  86% { opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ---------- Saludo inicial ---------- */

.hello {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 11%);
  transform: translateX(-50%);
  padding: 8px 26px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: clamp(1.15rem, 4.2vmin, 2rem);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #fff;
  box-shadow: 0 10px 24px rgba(229, 103, 159, 0.25);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  animation: helloPop 3.4s 0.7s ease forwards;
}

@keyframes helloPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.85); }
  14% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.06); }
  22% { transform: translateX(-50%) translateY(0) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.96); }
}

/* ---------- Aviso si falla la librería de física ---------- */

.load-error {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(217, 245, 232, 0.92);
  z-index: 10;
}

.load-error[hidden] {
  display: none;
}

.load-error-card {
  max-width: min(86vw, 420px);
  padding: 24px 28px;
  border-radius: 28px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 14px 36px rgba(229, 103, 159, 0.25);
}

.load-error-card button {
  margin-top: 8px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Pantallas muy pequeñas ---------- */

@media (max-width: 360px) {
  :root {
    --btn: 46px;
    --btn-big: 62px;
  }
}

/* ---------- Accesibilidad: menos movimiento ---------- */

@media (prefers-reduced-motion: reduce) {
  .sneeze-btn.attract,
  .sneeze-btn.attract::after {
    animation: none;
  }

  .bubble-btn {
    transition: none;
  }

  .hello {
    animation: none;
    opacity: 1;
  }

  .hello.gone {
    opacity: 0;
    transition: opacity 0.4s ease;
  }
}

.hello.gone {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .hello.gone {
    display: block;
  }
}
