:root {
  --bg: #fef3c7;
  --card: #ffffff;
  --card-2: #fdf2f8;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --accent-2: #8b5cf6;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Comic Sans MS', 'Trebuchet MS', 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, #fde68a 0, transparent 24%),
    radial-gradient(circle at 84% 20%, #bfdbfe 0, transparent 26%),
    radial-gradient(circle at 72% 80%, #fbcfe8 0, transparent 24%),
    linear-gradient(160deg, #fef3c7, #dbeafe 50%, #fce7f3);
}

.app {
  width: min(920px, 94vw);
  margin: 0 auto;
  padding: 10px 0 16px;
}

.app-header {
  margin-bottom: 8px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
}

.scanner-card,
.player-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(253, 242, 248, 0.9));
  border: 2px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius);
  padding: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 24px rgba(59, 130, 246, 0.2);
}

.player-card {
  margin-top: 8px;
}

.scanner-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 10px;
  align-items: stretch;
}

body:not(.camera-active) .scanner-main {
  grid-template-columns: 1fr;
}

.video-wrap {
  width: 100%;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: black;
  aspect-ratio: 4 / 3;
  max-height: 32vh;
}

body:not(.camera-active) .video-wrap {
  display: none;
}

#camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.scan-frame {
  width: min(52vw, 260px);
  aspect-ratio: 1;
  border: 4px solid rgba(139, 92, 246, 0.92);
  border-radius: 18px;
  box-shadow: inset 0 0 0 2000px rgba(17, 24, 39, 0.28), 0 0 16px rgba(139, 92, 246, 0.8);
}

.scan-hint {
  margin-top: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  color: #7c3aed;
}

.scan-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #f97316;
  box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5);
}

.scan-text {
  font-size: 1rem;
}

.invalid-qr {
  margin-top: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(254, 226, 226, 0.95);
  color: #b91c1c;
  font-weight: 800;
  border: 2px solid rgba(220, 38, 38, 0.22);
}

.invalid-icon {
  font-size: 1.2rem;
}

.status {
  margin: 10px 4px 4px;
  color: var(--muted);
  font-weight: 500;
}

.status.ok {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

#player {
  width: 100%;
  margin-top: 8px;
}

.music-animation {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 2px;
}

.yt-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  margin-top: 8px;
}

.yt-wrap iframe,
.yt-wrap > div {
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

.equalizer {
  height: 34px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.equalizer span {
  width: 8px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #22d3ee, #8b5cf6);
  animation: bars 0.75s ease-in-out infinite;
}

.equalizer span:nth-child(2) {
  animation-delay: 0.08s;
}

.equalizer span:nth-child(3) {
  animation-delay: 0.16s;
}

.equalizer span:nth-child(4) {
  animation-delay: 0.24s;
}

.equalizer span:nth-child(5) {
  animation-delay: 0.32s;
}

.music-note {
  font-size: 2rem;
  transform-origin: center;
  animation: dance 0.85s ease-in-out infinite;
}

.current-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.current-link:hover {
  color: #67e8f9;
  text-decoration: underline;
}

.scan-again {
  margin-top: 0;
  width: 100%;
  border: 0;
  border-radius: 20px;
  color: #1e1b4b;
  background: linear-gradient(120deg, #f9a8d4, #c4b5fd 45%, #93c5fd);
  min-height: 68px;
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  font-weight: 900;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(76, 29, 149, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

body.camera-active .scan-again {
  min-height: 100%;
}

.scan-again:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 26px rgba(76, 29, 149, 0.35);
}

.scan-again:active {
  transform: translateY(0);
}

.unlock-audio-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}

.unlock-audio-backdrop.visible {
  display: flex;
}

.unlock-audio {
  position: relative;
  z-index: 999;
  border: 0;
  border-radius: 20px;
  color: #312e81;
  background: linear-gradient(135deg, #fbcfe8, #ddd6fe 50%, #bfdbfe);
  min-height: 80px;
  min-width: min(80vw, 320px);
  padding: 0 28px;
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  font-weight: 900;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 20px 40px rgba(76, 29, 149, 0.45);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.unlock-audio-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.unlock-audio:hover {
  transform: scale(1.03);
  box-shadow: 0 24px 44px rgba(76, 29, 149, 0.5);
}

.unlock-audio:active {
  transform: scale(0.97);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.btn-camera-emoji {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(124, 58, 237, 0.13);
  border-radius: 10px;
}

.btn-icon svg {
  width: 25px;
  height: 25px;
  fill: #7c3aed;
}

/* ===== MASCOTES ===== */
.mascot {
  display: flex;
  justify-content: center;
  margin: 0 0 6px;
  min-height: 72px;
}

.mascot-scan,
.mascot-playing,
.mascot-invalid {
  display: none;
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.14));
}

body.needs-scan .mascot-scan {
  display: block;
  animation: owlBob 2s ease-in-out infinite;
}

body.is-playing .mascot-playing {
  display: block;
  animation: catDance 0.62s ease-in-out infinite;
}

body.invalid-qr-active .mascot-invalid {
  display: block;
  animation: bunnyShake 0.28s ease-in-out 5;
}

.owl-pupil-l,
.owl-pupil-r {
  transform-box: fill-box;
  transform-origin: center;
  animation: owlBlink 3.4s ease-in-out infinite;
}

.owl-pupil-r {
  animation-delay: 0.12s;
}

/* ===== FIM MASCOTES ===== */

body.is-scanning .scan-hint--camera {
  display: inline-flex;
  animation: floaty 1.25s ease-in-out infinite;
}

body.is-scanning .scan-dot {
  animation: ping 1.1s ease-out infinite;
}

body.is-idle .scan-hint--idle {
  display: inline-flex;
  animation: floaty 1.8s ease-in-out infinite;
}

body.is-playing .music-animation {
  display: flex;
}

body.invalid-qr-active .invalid-qr {
  display: inline-flex;
  animation: invalidPop 0.8s ease;
}

body.invalid-qr-active .scan-frame {
  border-color: rgba(239, 68, 68, 0.95);
  animation: frameShake 0.38s linear 2;
}

@keyframes bars {
  0%,
  100% {
    height: 10px;
  }
  50% {
    height: 34px;
  }
}

@keyframes dance {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
  }
  50% {
    transform: translateY(-5px) rotate(6deg);
  }
}

@keyframes ping {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5);
  }
  80% {
    transform: scale(1.1);
    box-shadow: 0 0 0 12px rgba(249, 115, 22, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes invalidPop {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  45% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes frameShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@keyframes owlBob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  40% {
    transform: translateY(-7px) rotate(-3deg);
  }
  60% {
    transform: translateY(-7px) rotate(3deg);
  }
}

@keyframes owlBlink {
  0%,
  85%,
  100% {
    transform: scaleY(1);
  }
  90% {
    transform: scaleY(0.08);
  }
  93% {
    transform: scaleY(1);
  }
}

@keyframes catDance {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg) scale(1);
  }
  50% {
    transform: translateY(-7px) rotate(4deg) scale(1.05);
  }
}

@keyframes bunnyShake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  25% {
    transform: translateX(-6px) rotate(-4deg);
  }
  75% {
    transform: translateX(6px) rotate(4deg);
  }
}

@media (max-width: 560px) {
  .app {
    width: 95vw;
    padding-top: 8px;
  }

  .scanner-card,
  .player-card {
    padding: 8px;
    border-radius: 14px;
  }

  .scan-again {
    min-height: 60px;
  }

  .scanner-main {
    grid-template-columns: 1fr;
  }

  body.camera-active .scan-again {
    min-height: 60px;
  }
}
