/* === Bubble Wrap additions === */

.bubble-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 600px;
  margin: 0 auto 0.75rem;
}

.bubble-count {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 500;
  color: var(--muted);
}

#sound-pill {
  gap: 0.4rem;
}

.sound-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.volume-slider {
  width: 96px;
  accent-color: var(--primary);
  cursor: pointer;
}

.volume-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Grid columns are set by JS from the chosen bubble size (fewer columns =
   bigger bubbles). Each bubble is 1fr with aspect-ratio 1, so any column count
   still fits the sheet width. */
.sheet {
  display: grid;
  grid-template-columns: repeat(10, 1fr);  /* placeholder; JS overrides inline */
  gap: 8px;
  max-width: 600px;
  padding: 1rem;
  margin: 0 auto 1.25rem;
  background: #eef6fe;
  border: 2px solid #cfe3f5;
  border-radius: 22px;
  box-shadow: 0 14px 30px rgba(70, 130, 190, 0.18);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.4s ease;   /* gentle cross-fade when a fresh sheet eases in */
}

/* Endless mode: cleared sheet fades out before the fresh one is built */
.sheet.refilling { opacity: 0; }

.bubble {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  padding: 0;
  border: none;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 32% 28%,
      #ffffff 0%,
      #eef7ff 22%,
      #cfe8fb 58%,
      #a6d2f1 100%);
  box-shadow:
    0 2px 5px rgba(70, 140, 200, 0.28),
    inset 0 3px 5px rgba(255, 255, 255, 0.8),
    inset 0 -4px 7px rgba(56, 120, 180, 0.25);
  transition: transform 0.12s ease;
}

@media (hover: hover) {
  .bubble:not(.popped):hover { transform: scale(1.06); }
}

.bubble:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px #7fb8e6,
    inset 0 3px 5px rgba(255, 255, 255, 0.8);
}

.bubble.popped {
  cursor: default;
  background: radial-gradient(circle at 50% 42%,
    #bcd8ee 0%,
    #d8ecfb 78%);
  box-shadow: inset 0 2px 6px rgba(56, 120, 180, 0.4);
  animation: bubblePop 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

/* Quick squish-down then a tiny overshoot back up for that springy give. */
@keyframes bubblePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.68); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(0.9); }
}

/* Expanding ring on pop — the "burst" of air escaping. */
.bubble.popped::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(120, 180, 230, 0.55);
  pointer-events: none;
  animation: popRing 0.4s ease-out forwards;
}

@keyframes popRing {
  0%   { opacity: 0.8; transform: scale(0.6); }
  100% { opacity: 0;   transform: scale(1.9); }
}

@media (prefers-reduced-motion: reduce) {
  .bubble.popped { animation: none; transform: scale(0.9); }
  .bubble.popped::after { display: none; }
  .confetti { display: none; }
  .celebrate { animation: none; }
  .sheet { transition: none; }
}

.bubble.popped:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px #7fb8e6,
    inset 0 2px 6px rgba(56, 120, 180, 0.4);
}

.bubble-actions {
  display: flex;
  gap: 0.6rem;
  max-width: 600px;
  margin: 0 auto;
}

#new-sheet {
  flex: 1;
  display: block;
}

#pop-all {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#pop-all:hover {
  background: #5eb5cd;
  border-color: #5eb5cd;
}

#pop-all:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.celebrate {
  max-width: 600px;
  margin: 0 auto 1rem;
  padding: 0.9rem 1rem;
  text-align: center;
  background: linear-gradient(135deg, var(--card) 0%, var(--pick-bg) 100%);
  border: 2px solid var(--pick-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: cardPop 0.35s cubic-bezier(0.17, 0.89, 0.32, 1.275);
}

.celebrate-msg {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--primary-dark);
}

.celebrate-time {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti i {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation-name: confettiFall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(-10px) translateX(0) rotate(0); }
  100% { opacity: 0; transform: translateY(105vh) translateX(var(--x)) rotate(var(--r)); }
}

/* Tighten spacing on small screens so the chosen grid still fits comfortably.
   (Column count is the user's size choice, applied inline by JS.) */
@media (max-width: 640px) {
  .sheet {
    gap: 4px;
    padding: 0.7rem;
  }
}

/* ---- bubble & sheet size pickers ---- */
.size-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.4rem;
  max-width: 600px;
  margin: 0 auto 0.9rem;
}

.size-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.size-label {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}

.size-btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  min-height: 40px;
}

.size-btn[aria-pressed="true"] {
  background: var(--pick-bg);
  border-color: var(--pick-border);
  color: var(--primary-dark);
  font-weight: 700;
}

.size-btn[aria-pressed="true"]:hover {
  border-color: var(--pick-border);
}

/* :hover sticks after a tap on touchscreens (Chromium keeps the tapped element
   hovered until you tap elsewhere), and the pink hover border looks just like the
   picked ring — so hover must never change these toggles' chrome, on any device.
   State is carried by the .picked / aria-pressed fill alone. The keyboard focus
   ring (base.css .pill:has(input:focus-visible)) is untouched. */
#endless-pill, #sound-pill, #haptic-pill,
#endless-pill:hover, #sound-pill:hover, #haptic-pill:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
#endless-pill.picked, #sound-pill.picked, #haptic-pill.picked,
#endless-pill.picked:hover, #sound-pill.picked:hover, #haptic-pill.picked:hover {
  border-color: var(--pick-border);
  transform: none;
  box-shadow: none;
}
.size-btn { -webkit-tap-highlight-color: transparent; }
.size-btn:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}
.size-btn[aria-pressed="true"]:hover {
  background: var(--pick-bg);
  border-color: var(--pick-border);
  color: var(--primary-dark);
}

/* In dark mode a ring alone reads as a stuck focus outline (the picked background
   is barely distinguishable), so "on" becomes a solid magenta fill instead —
   unmistakable at a glance. Light mode keeps its pink-tint + border look. */
html.dark #endless-pill.picked, html.dark #sound-pill.picked, html.dark #haptic-pill.picked,
html.dark #endless-pill.picked:hover, html.dark #sound-pill.picked:hover, html.dark #haptic-pill.picked:hover {
  background: var(--pick-border);
  border-color: var(--pick-border);
  color: #fff;
}
html.dark .size-btn[aria-pressed="true"],
html.dark .size-btn[aria-pressed="true"]:hover {
  background: var(--pick-border);
  border-color: var(--pick-border);
  color: #fff;
}

/* Screen-reader-only text — the throttled pop announcements live here. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
