/* ---------- base (mobile-first) ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- sky ---------- */
#sky {
  position: relative;
  width: 100%;
  height: 100vh;
  background: linear-gradient(to bottom, #7ec8f5 0%, #b4e2ff 55%, #e8f6ff 100%);
  overflow: hidden;
}

#sun {
  position: absolute;
  top: 6%; right: 8%;
  width: 70px; height: 70px;
  background: radial-gradient(circle at 35% 35%, #fff7a8 0%, #ffe24b 60%, #ffc400 100%);
  border-radius: 50%;
  box-shadow: 0 0 50px 8px rgba(255, 220, 90, 0.55);
  z-index: 1;
}

#ground {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: linear-gradient(to bottom, #8fd36a, #4ea83a);
  border-top: 4px solid #3d8a2f;
  z-index: 3;
}

/* ---------- title ---------- */
#title {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
  color: #fff;
  text-shadow: 2px 2px 0 #2a6fa0, 0 0 12px rgba(0,0,0,0.25);
  pointer-events: none;
  width: 90%;
}
#title h1 {
  margin: 0;
  font-size: clamp(1.2rem, 5.5vw, 2.4rem);
  letter-spacing: 1px;
  line-height: 1.15;
}
#title .subtitle {
  margin: 4px 0 0;
  font-size: clamp(0.8rem, 3vw, 1rem);
  opacity: 0.95;
}

/* ---------- clouds ---------- */
#clouds-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.cloud {
  position: absolute;
  will-change: transform;
}

.cloud svg {
  display: block;
  filter: drop-shadow(0 5px 8px rgba(30, 60, 90, 0.18));
}

/* ---------- balloons ---------- */
#balloons-row {
  position: absolute;
  left: 0; right: 0;
  bottom: 50px;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 0 8px;
  z-index: 4;
  pointer-events: none;
}

.balloon {
  /* single source of size — everything scales from this */
  --w: clamp(52px, 17vw, 110px);
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 2.05);
  flex: 0 0 auto;
  animation: sway 3.5s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.balloon[data-color="yellow"] { animation-delay: -0.7s; }
.balloon[data-color="blue"]   { animation-delay: -1.4s; }
.balloon[data-color="green"]  { animation-delay: -2.1s; }

/* balloon body */
.balloon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--w) * 0.92);
  height: calc(var(--w) * 1.22);
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.1) 22%, transparent 40%),
    radial-gradient(circle at 50% 55%, var(--bc) 0%, color-mix(in srgb, var(--bc) 70%, #000) 100%);
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  box-shadow: inset -6px -8px 16px rgba(0,0,0,0.18);
}

/* knot */
.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(var(--w) * 1.20);
  width: calc(var(--w) * 0.13);
  height: calc(var(--w) * 0.10);
  transform: translateX(-50%);
  background: var(--bc);
  clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%);
  filter: brightness(0.85);
}

.balloon::before,
.balloon::after { z-index: 2; }

/* string */
.balloon .str {
  position: absolute;
  left: 50%;
  top: calc(var(--w) * 1.30);
  width: 2px;
  height: calc(var(--w) * 0.78);
  background: rgba(80, 80, 80, 0.7);
  transform: translateX(-50%);
  z-index: 1;
}

/* pop animation */
.balloon.popping {
  animation: pop 0.45s ease-out forwards;
}
.balloon.popped {
  display: none;
}

@keyframes pop {
  0%   { transform: scale(1);   opacity: 1; }
  25%  { transform: scale(1.3); opacity: 1; }
  60%  { transform: scale(0.4) rotate(15deg); opacity: 0.5; }
  100% { transform: scale(0);   opacity: 0; }
}

@keyframes sway {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50%      { transform: rotate(2deg)  translateY(-6px); }
}

/* ---------- burst ---------- */
.burst {
  position: absolute;
  left: 50%; top: calc(var(--w) * 0.55);
  width: 0; height: 0;
  z-index: 5;
  pointer-events: none;
}
.burst .shard {
  position: absolute;
  left: 0; top: 0;
  width: 9px; height: 16px;
  background: var(--bc, #fff);
  border-radius: 2px;
  transform-origin: center;
  animation: shard-fly 0.6s ease-out forwards;
}
.burst .shard:nth-child(1) { --dx:  50px; --dy: -60px; --rot:  25deg; }
.burst .shard:nth-child(2) { --dx: -60px; --dy: -40px; --rot: -40deg; }
.burst .shard:nth-child(3) { --dx:  65px; --dy:  25px; --rot:  70deg; }
.burst .shard:nth-child(4) { --dx: -65px; --dy:  35px; --rot: -60deg; }
.burst .shard:nth-child(5) { --dx:   0px; --dy: -75px; --rot:   0deg; }
.burst .shard:nth-child(6) { --dx:  35px; --dy:  55px; --rot: 120deg; }
.burst .shard:nth-child(7) { --dx: -40px; --dy:  50px; --rot: -90deg; }
.burst .shard:nth-child(8) { --dx:  75px; --dy: -15px; --rot:  45deg; }

@keyframes shard-fly {
  0%   { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- mic overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 50, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in 0.3s ease both;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: #fff;
  padding: 28px 24px;
  border-radius: 20px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: pop-in 0.35s ease both;
}
.overlay-card h2 {
  margin: 8px 0 6px;
  color: #2c3e50;
  font-size: 1.4rem;
}
.overlay-card p {
  margin: 8px 0 18px;
  color: #55616e;
  line-height: 1.45;
  font-size: 0.95rem;
}
.overlay-card .mic-icon {
  color: #3498db;
  display: inline-flex;
  padding: 12px;
  background: #eaf4fc;
  border-radius: 50%;
}

.overlay-card button,
#reset-btn {
  background: #3498db;
  color: #fff;
  border: 0;
  font: inherit;
  font-size: 1rem;
  padding: 12px 24px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a80b9;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.overlay-card button:hover,
#reset-btn:hover { transform: translateY(-1px); }
.overlay-card button:active,
#reset-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2a80b9;
}

.overlay-card button.secondary {
  background: transparent;
  color: #3498db;
  font-size: 0.85rem;
  padding: 6px 14px;
  box-shadow: none;
  text-decoration: underline;
  margin-top: -4px;
}
.overlay-card button.secondary:hover { transform: none; }
.overlay-card button.secondary:active { transform: translateY(1px); box-shadow: none; }

#reset-btn {
  position: absolute;
  bottom: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: #e67e22;
  box-shadow: 0 4px 0 #b36416;
  font-size: 0.9rem;
  padding: 10px 20px;
}
#reset-btn[hidden] { display: none; }

.error {
  color: #c0392b;
  font-size: 0.9rem;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  #sun { width: 110px; height: 110px; top: 8%; right: 10%; }
  #ground { height: 70px; }
  #balloons-row { bottom: 70px; }
  #reset-btn { bottom: 90px; font-size: 1rem; padding: 12px 24px; }
  #title { top: 20px; }
}

/* ---------- secret settings overlay ---------- */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
}
.settings-overlay.hidden { display: none; }

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 100%, rgba(10, 30, 50, 0.55), rgba(5, 15, 30, 0.75));
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  animation: fade-in 0.22s ease both;
}

.settings-panel {
  position: relative;
  width: min(460px, 100%);
  max-height: 88vh;
  margin: 0 12px;
  padding: 18px 22px 24px;
  border-radius: 22px 22px 18px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,249,255,0.96));
  box-shadow:
    0 -8px 40px rgba(10, 30, 60, 0.35),
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 0 0 1px rgba(255,255,255,0.6) inset;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1f2d3d;
  overflow-y: auto;
  animation: panel-up 0.32s cubic-bezier(.2,.9,.25,1) both;
}

@media (min-width: 700px) {
  .settings-overlay { align-items: center; }
  .settings-panel { margin: 0; border-radius: 20px; }
  .settings-handle { display: none; }
}

.settings-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.15);
  margin: 0 auto 12px;
}

.settings-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: #2c3e50;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.settings-close:hover { background: rgba(0,0,0,0.12); }
.settings-close:active { transform: scale(0.94); }

.settings-header {
  margin: 4px 36px 18px 4px;
}
.settings-header h2 {
  margin: 0 0 2px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f2239;
}
.settings-header p {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.35;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.setting-row label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #223349;
  letter-spacing: 0.01em;
}
.setting-row output {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 600;
  color: #3498db;
  padding: 2px 8px;
  background: rgba(52,152,219,0.10);
  border-radius: 999px;
}

/* range slider */
.setting input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
.setting input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3498db var(--fill, 50%), rgba(0,0,0,0.08) var(--fill, 50%));
}
.setting input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
}
.setting input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: #3498db;
}
.setting input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #3498db;
  box-shadow: 0 2px 6px rgba(52,152,219,0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.setting input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #3498db;
  box-shadow: 0 2px 6px rgba(52,152,219,0.45);
}
.setting input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(52,152,219,0.6);
}

.select-wrap {
  position: relative;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid #3498db;
  border-bottom: 2px solid #3498db;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.setting select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: #1f2d3d;
  padding: 11px 36px 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.setting select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.22);
}

.settings-reset {
  align-self: flex-start;
  margin-top: 6px;
  background: transparent;
  border: 0;
  color: #64748b;
  font: inherit;
  font-size: 0.82rem;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.settings-reset:hover { color: #3498db; }

@keyframes panel-up {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
