.intro-overlay {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: radial-gradient(circle at center, #3d0000 0%, #1a0000 50%, #0d0000 100%);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 1s ease, visibility 1s ease;
  touch-action: none;
  overscroll-behavior: none;
}

.intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-overlay[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.intro-heart {
  position: absolute;
  font-size: 20px;
  color: var(--accent);
  opacity: 0;
  animation: floatHeart 4s ease-in-out infinite;
  z-index: 5001;
}

@keyframes floatHeart {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-20px) rotate(10deg);
    opacity: 1;
  }
}

.intro-center-heart-wrapper {
  font-size: 150px;
  color: var(--accent);
  opacity: 0;
  transform: scale(0);
  display: none;
  animation: heartConverge 2s ease-out forwards;
  animation-delay: 2s;
  z-index: 5002;
  perspective: 1000px;
}

.intro-center-heart-wrapper.show {
  animation-delay: 0s;
}

.intro-center-heart-wrapper.show {
  display: block;
}

.drag-hint {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 5003;
  position: fixed;
  top: 65%;
  left: 50%;
  transform: translateX(-50%) scale(0.3);
  transition: opacity 1s ease-out, transform 1s ease-out;
}

.drag-hint.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
  animation: heartbeat 1s ease-in-out infinite;
  animation-delay: 1s;
}

@keyframes heartbeat {
  0%, 100% {
    transform: translateX(-50%) scale(1);
  }
  10% {
    transform: translateX(-50%) scale(1.08);
  }
  25% {
    transform: translateX(-50%) scale(1.05);
  }
}

.intro-start-stack {
  --intro-button-height: 56px;
  position: fixed;
  left: 50%;
  top: 50%;
  height: var(--intro-button-height);
  transform: translate(-50%, -50%);
  z-index: 5003;
  pointer-events: none;
}

.intro-start-btn {
  --intro-button-height: 56px;
  position: relative;
  height: var(--intro-button-height);
  padding: 0 32px;
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ff6b9d, #c44569);
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(196, 69, 105, 0.4);
  transition: all 0.3s ease;
  z-index: 1;
  pointer-events: auto;
  animation: pulse 2s ease-in-out infinite;
}

.intro-start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(196, 69, 105, 0.5);
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.intro-gate {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%) translateY(16px);
  width: min(340px, calc(100vw - 32px));
  padding: 22px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  background: rgba(18, 4, 8, 0.82);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
  color: #fff;
  text-align: center;
  z-index: 5004;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.intro-gate.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.intro-gate.shake {
  animation: gateShake 0.35s ease;
}

.intro-gate-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.55rem;
}

.intro-gate-title {
  font-weight: 800;
  font-size: 1.05rem;
}

.intro-gate-hint {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.92rem;
}

.intro-gate-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.intro-gate-box {
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.intro-gate-box.filled {
  border-color: rgba(255, 143, 171, 0.95);
  background: rgba(255, 92, 138, 0.22);
}

.intro-gate.locked .intro-gate-boxes {
  opacity: 0.35;
}

.intro-gate-input {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  width: 240px;
  height: 44px;
  opacity: 0;
  font-size: 16px;
  transform: translateX(-50%);
}

.intro-gate-error {
  min-height: 18px;
  margin-top: 10px;
  color: #ffb4c8;
  font-size: 0.86rem;
  opacity: 0;
}

.intro-gate-error.visible {
  opacity: 1;
}

.intro-gate-lock-message {
  display: none;
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
}

.intro-gate.locked .intro-gate-lock-message {
  display: block;
}

.intro-gate-timer {
  min-height: 30px;
  margin-top: 4px;
  color: #ffd6e2;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0;
}

@keyframes gateShake {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  25% { transform: translateX(calc(-50% - 7px)) translateY(0); }
  50% { transform: translateX(calc(-50% + 7px)) translateY(0); }
  75% { transform: translateX(calc(-50% - 4px)) translateY(0); }
}

.foca1 {
  --foca1-width: 100px;
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  width: var(--foca1-width);
  height: auto;
  z-index: 2;
  pointer-events: none;
}

#heartCanvas {
  width: 100vw;
  height: 100vh;
  cursor: grab;
  background: radial-gradient(circle at center, #3d0000 0%, #1a0000 50%, #0d0000 100%);
}

#heartCanvas:active {
  cursor: grabbing;
}

@keyframes heartConverge {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes heartPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes layerPulse {
  0%, 100% {
    transform: translateZ(var(--z)) scale(1);
  }
  50% {
    transform: translateZ(var(--z)) scale(1.05);
  }
}

@keyframes heartRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.intro-center-heart.exploding {
  animation: heartExplode 0.8s ease-out forwards;
}

@keyframes heartExplode {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(2);
  }
}

.explosion-heart {
  position: fixed;
  font-size: 24px;
  pointer-events: none;
  z-index: 1000;
  animation: explodeHeart 1s ease-out forwards;
}

@keyframes explodeHeart {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(1.5);
  }
}

.intro-text {
  position: absolute;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  opacity: 0;
  animation: textFadeIn 1.5s ease-out 2.5s forwards;
}

@keyframes textFadeIn {
  to { opacity: 1; }
}

@media (max-width: 768px) {
  .intro-gate {
    top: 10%;
    padding: 18px 16px 16px;
  }

  .intro-gate-box {
    height: 38px;
  }

  .intro-heart {
    font-size: 16px;
  }

  .explosion-heart {
    font-size: 18px;
  }

  .intro-text {
    font-size: 1.5rem;
  }

  .foca1 {
    --foca1-width: 80px;
  }
}

@media (max-height: 620px) {
  .intro-gate {
    top: 6%;
  }

  .intro-gate-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 6px;
    font-size: 1.25rem;
  }
}
