/* BUBBLES — web game */
:root {
  --bg-deep: #0a0a1a;
  --border: #1e1e3a;
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2d78;
  --neon-purple: #b24dff;
  --neon-gold: #ffd700;
  --text-primary: #e8e8f0;
  --text-secondary: #9090b0;
  --font-main: 'Space Grotesk', system-ui, sans-serif;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
html, body { height: 100%; overflow-x: hidden; }

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  user-select: none;
}

/* ─── Topbar ─── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  background: rgba(10, 10, 26, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1e1e3a;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: color .2s;
}
.back-link:hover { color: var(--neon-cyan); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cta-case {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  padding: 0.25rem 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}
.cta-case:hover { color: var(--neon-cyan); }
.cta-case-mobile { display: none; }
@media (max-width: 640px) {
  .cta-case-desktop { display: none; }
  .cta-case-mobile { display: inline; }
}

.score-display { display: flex; align-items: center; gap: .5rem; }
.score-display[hidden] { display: none; }
.score-label {
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.score-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--neon-cyan);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(0,240,255,.5);
}

/* ─── Game area ─── */
.game-area {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 56px;
  touch-action: manipulation;
}

/* Empty state: pocas burbujas lentas detrás del CTA Play */
.splash-preview {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.game-area.is-playing .splash-preview { display: none; }

.bubble-preview {
  position: absolute;
  left: var(--preview-left, 50%);
  bottom: -60px;
  width: var(--preview-size, 28px);
  height: var(--preview-size, 28px);
  border-radius: 50%;
  animation: floatUpPreview var(--preview-dur, 16s) linear var(--preview-delay, 0s) infinite;
  will-change: transform, opacity;
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.3) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(173,216,255,.1) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(200,225,255,.05) 0%, rgba(180,210,255,.02) 100%);
  border: 1px solid rgba(180, 220, 255, .25);
  box-shadow: inset 0 0 16px rgba(200, 230, 255, .06), 0 0 6px rgba(160, 210, 255, .1);
}
.bubble-preview::before {
  content: '';
  position: absolute;
  top: 12%; left: 15%;
  width: 35%; height: 25%;
  background: radial-gradient(ellipse, rgba(255,255,255,.45) 0%, transparent 70%);
  border-radius: 50%;
  transform: rotate(-25deg);
}
@keyframes floatUpPreview {
  0% { translate: 0 0; opacity: .75; }
  85% { opacity: .5; }
  100% { translate: 0 calc(-100vh - 80px); opacity: 0; }
}

.splash, .game-over {
  text-align: center;
  z-index: 50;
  position: relative;
  animation: fadeIn .5s var(--ease-out) both;
  max-width: 420px;
  padding: 2rem;
}
.splash[hidden], .game-over[hidden] { display: none; }

.splash-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--neon-cyan);
  text-shadow: 0 0 7px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 42px rgba(0,240,255,.4);
  margin-bottom: .75rem;
  text-transform: uppercase;
}
.splash-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.go-label {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--neon-pink);
  text-shadow: 0 0 12px rgba(255,45,120,.5);
  margin-bottom: .5rem;
}
.go-score {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.go-score span { color: var(--neon-cyan); font-weight: 700; }

.game-over .vote-widget--go {
  margin: 1.5rem auto 0;
  text-align: center;
}
.game-over .vote-widget--go .vote-nums {
  justify-content: center;
}

.btn-start {
  padding: .8rem 2.5rem;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg-deep);
  background: var(--neon-cyan);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
  transition: transform .15s ease, box-shadow .25s ease;
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(0,240,255,.4);
}
.btn-start:active { transform: translateY(0); }

/* ─── Sound on pill (during play): tap to unlock device audio ─── */
.sound-on-pill {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: rgba(10, 10, 26, .85);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-family: var(--font-main);
  color: var(--text-secondary);
  cursor: pointer;
  transition: opacity 0.4s var(--ease-out), border-color 0.2s, color 0.2s;
}
.sound-on-pill:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}
.sound-on-pill.sound-on-pill--active {
  color: var(--neon-cyan);
  border-color: rgba(0, 240, 255, 0.4);
}
.sound-on-pill.sound-on-pill--active .sound-on-pill-label { font-style: normal; }
.sound-on-pill:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.2);
}
.sound-on-pill[hidden],
.game-area:not(.is-playing) .sound-on-pill { display: none !important; }
.sound-on-pill svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  flex-shrink: 0;
}
@media (max-width: 700px) {
  .sound-on-pill {
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: calc(12px + env(safe-area-inset-left));
  }
}

/* ─── Timer bar ─── */
.timer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 4px;
  width: 100%;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
  transform-origin: left;
  transform: scaleX(1);
  transition: transform linear;
  z-index: 100;
  opacity: 0;
}
.timer-bar.active { opacity: 1; }

/* ─── Bubbles ─── */
.game-area.is-playing .splash,
.game-area.is-playing .game-over { display: none; }
.game-area.is-playing { padding: 0; align-items: stretch; justify-content: stretch; }

.bubble {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  animation: floatUp var(--dur) linear forwards;
  will-change: transform, opacity;
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.35) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(173,216,255,.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(200,225,255,.06) 0%, rgba(180,210,255,.03) 100%);
  border: 1px solid rgba(180, 220, 255, .3);
  box-shadow: inset 0 0 20px rgba(200, 230, 255, .08), 0 0 8px rgba(160, 210, 255, .15);
}
.bubble::before {
  content: '';
  position: absolute;
  top: 12%; left: 15%;
  width: 35%; height: 25%;
  background: radial-gradient(ellipse, rgba(255,255,255,.5) 0%, transparent 70%);
  border-radius: 50%;
  transform: rotate(-25deg);
}
.bubble::after {
  content: '';
  position: absolute;
  bottom: 18%; right: 15%;
  width: 20%; height: 12%;
  background: radial-gradient(ellipse, rgba(200,230,255,.25) 0%, transparent 70%);
  border-radius: 50%;
  transform: rotate(15deg);
}

.bubble--special {
  border: 2px solid rgba(255, 255, 255, .7);
  animation: floatUp var(--dur) linear forwards, shimmer .6s ease-in-out infinite, pulse .4s ease-in-out infinite alternate;
  box-shadow:
    inset 0 0 30px rgba(255, 200, 255, .25),
    0 0 25px rgba(200, 100, 255, .6),
    0 0 50px rgba(180, 80, 255, .4),
    0 0 80px rgba(255, 100, 200, .25),
    0 0 120px rgba(100, 200, 255, .15);
}
.bubble--special::before {
  width: 110%; height: 110%;
  top: -5%; left: -5%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255,50,120,.3), rgba(255,215,0,.3), rgba(0,240,255,.3), rgba(178,77,255,.3), rgba(255,50,120,.3));
  animation: rainbowSpin 1s linear infinite;
}
.bubble--special::after {
  width: 100%; height: 100%; bottom: 0; right: 0; top: 0; left: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.7) 0%, transparent 40%);
}

@keyframes shimmer {
  0%, 100% { box-shadow: inset 0 0 30px rgba(255,200,255,.25), 0 0 25px rgba(200,100,255,.6), 0 0 50px rgba(180,80,255,.4), 0 0 80px rgba(255,100,200,.25), 0 0 120px rgba(100,200,255,.15); }
  33% { box-shadow: inset 0 0 30px rgba(200,255,230,.25), 0 0 25px rgba(0,240,200,.6), 0 0 50px rgba(0,200,255,.4), 0 0 80px rgba(100,255,200,.25), 0 0 120px rgba(200,255,100,.15); }
  66% { box-shadow: inset 0 0 30px rgba(255,220,180,.25), 0 0 25px rgba(255,180,50,.6), 0 0 50px rgba(255,100,150,.4), 0 0 80px rgba(255,50,120,.25), 0 0 120px rgba(255,200,100,.15); }
}
@keyframes pulse { from { scale: 1; } to { scale: 1.08; } }
@keyframes rainbowSpin { to { transform: rotate(360deg); } }

.glitter {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  pointer-events: none;
  animation: glitterBurst var(--gdur) ease-out forwards;
  z-index: 60;
}
@keyframes glitterBurst {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--gx), var(--gy)) scale(0); }
}

@keyframes floatUp {
  0% { translate: 0 0; opacity: .9; }
  80% { opacity: .7; }
  100% { translate: 0 calc(-100vh - 120px); opacity: 0; }
}
@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: .5; }
  100% { transform: scale(0); opacity: 0; }
}
@keyframes scoreFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

.score-pop {
  position: absolute;
  font-size: .9rem;
  font-weight: 700;
  pointer-events: none;
  animation: scoreFloat .6s var(--ease-out) forwards;
  z-index: 60;
}
.score-pop--normal { color: var(--neon-gold); text-shadow: 0 0 8px rgba(255,215,0,.5); }
.score-pop--special { color: var(--neon-purple); text-shadow: 0 0 10px rgba(178,77,255,.5); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Case modal: From idea to prototype ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.25s var(--ease-out);
}
.modal-overlay.is-open {
  display: flex;
  opacity: 1;
}
@media (min-width: 640px) {
  .modal-overlay.is-open { align-items: center; padding: 2rem; }
}
.modal-panel {
  position: relative;
  width: 100%;
  max-height: 85vh;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-out);
  overflow: hidden;
}
.modal-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
  z-index: 1;
}
.modal-overlay.is-open .modal-panel {
  transform: translateY(0);
}
@media (min-width: 640px) {
  .modal-panel {
    max-width: 440px;
    max-height: 80vh;
    border-radius: 16px;
    transform: scale(0.95);
  }
  .modal-panel::before {
    border-radius: 16px 16px 0 0;
  }
  .modal-overlay.is-open .modal-panel {
    transform: scale(1);
  }
  .modal-title { text-shadow: 0 0 20px rgba(255, 45, 120, 0.3); }
  .modal-close { background: rgba(255, 255, 255, 0.04); border-radius: 10px; }
  .modal-body .label { color: var(--neon-cyan); opacity: 0.9; }
  .modal-cta .btn-primary { box-shadow: 0 0 20px rgba(255, 45, 120, 0.25); }
  .modal-cta .btn-secondary { color: var(--neon-cyan); border-color: rgba(0, 240, 255, 0.35); }
  .modal-cta .btn-secondary:hover { box-shadow: 0 0 16px rgba(0, 240, 255, 0.2); }
}
.modal-drag {
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0.75rem auto 0;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .modal-drag { display: none; }
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.modal-header-text { min-width: 0; }
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neon-pink);
  margin: 0;
}
.modal-subtitle {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.modal-body {
  padding: 1rem 1.25rem 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-body .label {
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0.75rem 0 0.25rem;
}
.modal-body .label:first-child { margin-top: 0; }
.modal-body p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 0.35rem;
}
.modal-body p strong { color: var(--text-primary); }
.modal-cta {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.modal-cta a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  font-family: var(--font-main);
  transition: box-shadow 0.2s, transform 0.2s;
}
.modal-cta .btn-primary {
  background: var(--neon-pink);
  color: #0a0a1a;
  border: none;
}
.modal-cta .btn-primary:hover {
  box-shadow: 0 0 20px rgba(255, 45, 120, 0.4);
  transform: translateY(-1px);
}
.modal-cta .btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.modal-cta .btn-secondary:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}
@media (max-width: 639px) {
  .modal-panel { border-radius: 20px 20px 0 0; }
  .modal-panel::before { border-radius: 20px 20px 0 0; }
  .modal-drag { width: 48px; height: 4px; margin: 0.7rem auto 0; }
  .modal-header { padding: 0.85rem 1rem; }
  .modal-title { text-shadow: 0 0 20px rgba(255, 45, 120, 0.3); }
  .modal-close { background: rgba(255, 255, 255, 0.04); border-radius: 10px; }
  .modal-body .label { color: var(--neon-cyan); opacity: 0.9; }
  .modal-cta .btn-primary { box-shadow: 0 0 20px rgba(255, 45, 120, 0.25); }
  .modal-cta .btn-secondary { color: var(--neon-cyan); border-color: rgba(0, 240, 255, 0.35); }
  .modal-cta .btn-secondary:hover { border-color: var(--neon-cyan); box-shadow: 0 0 16px rgba(0, 240, 255, 0.2); }
}

.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer a { color: var(--text-secondary); text-decoration: none; }

.footer a:hover { color: var(--neon-cyan); }

@media (max-width: 700px) {
  .topbar {
    padding: .75rem 1rem;
    padding-top: calc(.75rem + env(safe-area-inset-top));
  }

  .back-link {
    padding: .25rem .5rem;
    margin: -.25rem -.5rem;
  }

  .game-area {
    padding-top: calc(56px + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }

  .btn-start {
    font-size: 1.05rem;
    min-height: 52px;
    padding: .9rem 2.75rem;
  }

  .timer-bar {
    bottom: env(safe-area-inset-bottom);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Vote widget */
.vote-widget {
  font: inherit;
  background: transparent;
  padding: 0.75rem 1.25rem;
  text-align: right;
  margin-left: auto;
  width: fit-content;
}
.vote-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary, #9090b0);
  margin-bottom: 0.25rem;
}
.vote-nums {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.vote-num {
  cursor: pointer;
  color: var(--text-secondary, #9090b0);
  transition: color 0.15s;
  min-width: 1.2em;
  text-align: center;
}
.vote-num:hover {
  color: var(--neon-pink, #ff2d78);
}
.vote-num.vote-selected {
  color: var(--neon-pink, #ff2d78);
}
.vote-num.vote-grey {
  color: var(--text-secondary, #666);
}
.vote-thanks {
  font-size: 0.75rem;
  color: var(--text-secondary, #666);
  margin-left: 0.5rem;
}
