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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background-attachment: fixed;
  padding: 0 1rem 4rem;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-size: 280px 280px, 320px 320px, 240px 240px, 360px 360px, 200px 200px, 300px 300px;
  opacity: 0.5;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.22  0 0 0 0 0.12  0 0 0 0 0.1  0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
}

/* Now playing banner */
.now-playing {
  position: sticky;
  top: 0;
  z-index: 100;
  margin: 0 -1rem;
  padding: 0.75rem 1.25rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 6px 20px rgba(58, 30, 27, 0.18);
  transform: translateY(-110%);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.now-playing.active { transform: translateY(0); }

.np-emoji {
  font-size: 1.85rem;
  line-height: 1;
  animation: bob 0.55s ease-in-out infinite alternate;
}
.np-label {
  flex: 1;
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.np-label em {
  font-family: 'Caveat', cursive;
  font-style: normal;
  font-size: 1.25em;
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.25rem;
}
.np-eq {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 22px;
}
.np-eq span {
  width: 4px;
  background: var(--ink);
  border-radius: 2px;
  animation: eq 0.85s ease-in-out infinite;
}
.np-eq span:nth-child(1) { animation-delay: 0s;    height: 60%; }
.np-eq span:nth-child(2) { animation-delay: 0.18s; height: 95%; }
.np-eq span:nth-child(3) { animation-delay: 0.36s; height: 70%; }
.np-stop {
  background: var(--ink);
  border: 0;
  color: var(--bg);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  transition: transform 0.15s ease;
}
.np-stop:hover { transform: scale(1.05); }
.np-stop:active { transform: scale(0.95); }

@keyframes eq {
  0%, 100% { transform: scaleY(0.35); }
  50%      { transform: scaleY(1); }
}
@keyframes bob {
  from { transform: translateY(0)    rotate(-6deg); }
  to   { transform: translateY(-4px) rotate(6deg); }
}

/* Header */
header {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 0.5rem clamp(1.25rem, 3.5vw, 2rem);
  text-align: center;
  position: relative;
  z-index: 2;
}
h1 {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: clamp(2.75rem, 9vw, 6rem);
  line-height: 0.95;
  margin: 0 0 0.4rem;
  color: var(--ink);
  letter-spacing: -0.005em;
  animation: titleIn 0.95s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  text-wrap: balance;
}
h1 .name { color: var(--accent); }
h1 .pop {
  display: inline-block;
  transform-origin: 50% 80%;
  animation: spin 5s ease-in-out infinite;
  margin-left: 0.15em;
}
.subtitle {
  font-family: 'Nunito', sans-serif;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1rem, 2.6vw, 1.4rem);
  color: var(--ink-soft);
  margin: 0;
  animation: titleIn 0.95s 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.subtitle b {
  font-style: normal;
  font-weight: 900;
  font-family: 'Caveat', cursive;
  font-size: 1.4em;
  letter-spacing: 0.01em;
}
.subtitle .e { color: #1F8FFF; }
.subtitle .n { color: var(--accent); }
.subtitle .heart {
  color: var(--accent);
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

.deco {
  position: absolute;
  pointer-events: none;
  opacity: 0.55;
  animation: float 7s ease-in-out infinite;
  filter: drop-shadow(0 3px 0 rgba(58, 30, 27, 0.1));
}
.deco-1 { top: 18%; left: 5%;  font-size: clamp(1.5rem, 4vw, 2.5rem); animation-delay: 0s; }
.deco-2 { top: 8%;  right: 7%; font-size: clamp(1.25rem, 3.2vw, 2rem); animation-delay: 1.2s; }
.deco-3 { bottom: 20%; left: 12%; font-size: clamp(1rem, 2.5vw, 1.6rem); animation-delay: 2s; }
.deco-4 { bottom: 10%; right: 10%; font-size: clamp(1.25rem, 3.2vw, 2rem); animation-delay: 0.6s; }

@keyframes titleIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}
@keyframes spin {
  0%, 100% { transform: rotate(-12deg) scale(1);    }
  50%      { transform: rotate(12deg)  scale(1.12); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1);    }
  50%      { transform: scale(1.28); }
}
@keyframes float {
  0%, 100% { transform: translateY(0)     rotate(-8deg); }
  50%      { transform: translateY(-12px) rotate(8deg);  }
}

/* Grid */
main {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

.sound-btn {
  --card: var(--c1);
  position: relative;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 1.5rem;
  padding: 1.1rem 0.7rem 0.85rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  min-height: 158px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.25s ease;
  animation: cardIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 38ms + 0.4s);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.sound-btn:nth-child(7n+1) { --card: var(--c1); }
.sound-btn:nth-child(7n+2) { --card: var(--c2); }
.sound-btn:nth-child(7n+3) { --card: var(--c3); }
.sound-btn:nth-child(7n+4) { --card: var(--c4); }
.sound-btn:nth-child(7n+5) { --card: var(--c5); }
.sound-btn:nth-child(7n+6) { --card: var(--c6); }
.sound-btn:nth-child(7n+7) { --card: var(--c7); }

@media (hover: hover) {
  .sound-btn:hover {
    transform: translateY(-4px) rotate(-1.2deg);
    box-shadow: var(--shadow-lg);
  }
  .sound-btn:hover .emoji {
    transform: scale(1.18) rotate(-4deg);
  }
}
.sound-btn:active {
  transform: translateY(2px) rotate(0);
  box-shadow: 0 1px 0 rgba(58, 30, 27, 0.18);
  transition-duration: 0.05s;
}

.sound-btn .emoji {
  font-size: clamp(2.4rem, 5.5vw, 3.1rem);
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(58, 30, 27, 0.18));
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sound-btn .label {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.005em;
  hyphens: auto;
}
.sound-btn .child {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  opacity: 0.7;
  margin-top: auto;
  padding-top: 0.25rem;
}

/* Playing state */
.sound-btn.playing {
  animation: cardIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             wobble 1.1s ease-in-out infinite 0.6s;
  animation-delay: calc(var(--i, 0) * 38ms + 0.4s), 0s;
  z-index: 3;
}
.sound-btn.playing::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 1.85rem;
  pointer-events: none;
  box-shadow: 0 0 0 0 var(--accent-glow, rgba(232, 74, 110, 0.65));
  animation: ring 1.4s ease-out infinite;
}
.sound-btn.playing .emoji {
  animation: emojiHop 0.7s ease-in-out infinite alternate;
}
@keyframes ring {
  0%   { box-shadow: 0 0 0 0    var(--accent-glow, rgba(232, 74, 110, 0.7)); }
  100% { box-shadow: 0 0 0 16px transparent; }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-1.6deg); }
  50%      { transform: rotate(1.6deg);  }
}
@keyframes emojiHop {
  from { transform: translateY(0)    scale(1);    }
  to   { transform: translateY(-6px) scale(1.08); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(15px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

footer {
  max-width: 1100px;
  margin: 3rem auto 0;
  text-align: center;
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: var(--ink-soft);
  position: relative;
  z-index: 2;
}
footer .doodle {
  display: block;
  font-size: 1.6rem;
  margin-top: 0.25rem;
  letter-spacing: 0.4em;
}

@media (max-width: 480px) {
  body { padding: 0 0.75rem 3rem; }
  .now-playing { margin: 0 -0.75rem; padding: 0.65rem 1rem; gap: 0.6rem; }
  .np-emoji { font-size: 1.55rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.7rem; }
  .sound-btn { min-height: 138px; border-width: 2.5px; padding: 0.95rem 0.55rem 0.7rem; }
  .sound-btn .label { font-size: 0.78rem; }
  .sound-btn .child { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.05s !important;
  }
}
