.modal-animation {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #FFF;
  touch-action: none;
  font-family: var(--font-primary);
  color: #000;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  z-index: var(--z-modal-animation);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
}

.modal-animation.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-animation::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, transparent 70%);
  opacity: 0;
  mix-blend-mode: overlay;
  transition: opacity 0.5s ease-in-out 0.4s;
}

.modal-animation.is-visible::after {
  opacity: 0.4;
}

.modal-animation-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.modal-animation-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  padding: clamp(1rem, 5vw, 3.75rem);
}

@supports (padding: env(safe-area-inset-top)) {
  .modal-animation-ui {
    padding-top: max(clamp(1rem, 5vw, 3.75rem), env(safe-area-inset-top));
    padding-bottom: max(clamp(1rem, 5vw, 3.75rem), env(safe-area-inset-bottom));
    padding-left: max(clamp(1rem, 5vw, 3.75rem), env(safe-area-inset-left));
    padding-right: max(clamp(1rem, 5vw, 3.75rem), env(safe-area-inset-right));
  }
}

.modal-animation-status {
  justify-self: center;
  align-self: center;
  font-size: clamp(0.625rem, 2.2vw, 1.75rem);
  letter-spacing: clamp(0.1em, 0.5vw, 0.2em);
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  color: rgba(0,0,0,0.85);
  text-align: center;
}

.modal-animation-status.is-visible {
  opacity: 0.5;
  transform: translateY(0);
}

.modal-animation-breath {
  justify-self: center;
  align-self: start;
  text-align: center;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-animation-breath.is-active {
  opacity: 1;
  transform: scale(1);
}

.modal-animation-breath-phase {
  font-size: clamp(0.625rem, 1.8vw, 1.125rem);
  letter-spacing: clamp(0.15em, 0.5vw, 0.3em);
  margin-bottom: var(--space-xs);
  opacity: 0.7;
  color: rgba(0,0,0,0.65);
}

.modal-animation-breath-timer {
  font-size: clamp(2rem, 10vw, 8.75rem);
  font-weight: 800;
  line-height: 1;
  color: #000;
}

.modal-animation-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0,0,0,0.08);
  z-index: 20;
}

.modal-animation-progress-fill {
  height: 100%;
  width: 0%;
  background: #000;
  box-shadow: 0 0 15px rgba(0,0,0,0.3);
  transition: width 0.2s ease-out;
}

.modal-animation-ready {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.5rem, 10vw, 9rem);
  font-weight: 900;
  letter-spacing: clamp(0.05em, 0.3vw, 0.15em);
  color: rgba(0,0,0,0.9);
  text-shadow: 0 4px 40px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 1.8s ease-out;
  text-align: center;
  padding: var(--space-lg);
  word-break: break-word;
}

.modal-animation-ready.is-active {
  opacity: 1;
}

.modal-animation-cursor {
  display: inline-block;
  width: clamp(4px, 1.5vw, 10px);
  height: 1.1em;
  background: #000;
  margin-left: 4px;
  animation: blink 1s steps(1) infinite;
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
}

.modal-messages {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 240, 240, 0.95);
  backdrop-filter: blur(5px);
  z-index: var(--z-modal-messages);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: var(--space-md);
}

.modal-messages.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-messages-window {
  max-width: min(500px, calc(100vw - 2rem));
  width: 100%;
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-messages-title {
  font-size: clamp(1.125rem, 3vw, 1.5rem);
  margin-bottom: var(--space-md);
  color: var(--color-text-primary);
}

.modal-messages-content {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.modal-messages-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
  align-items: center;
}

.modal-messages-button {
  min-height: var(--touch-min);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: clamp(0.875rem, 2vw, 1rem);
  cursor: pointer;
  transition: all var(--transition-base);
  flex: 1 1 auto;
  min-width: 120px;
}

.modal-messages-button--secondary {
  border: 1px solid var(--color-border);
  background: white;
  color: var(--color-text-primary);
}

.modal-messages-button--secondary:hover {
  background: var(--color-bg-secondary);
}

.modal-messages-button--primary {
  border: 1px solid var(--color-text-primary);
  background: var(--color-text-primary);
  color: white;
}

.modal-messages-button--primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

@media (max-width: 240px) {
  .modal-animation-ui {
    padding: 0.5rem;
  }
  
  .modal-animation-status {
    font-size: 0.5rem;
  }
  
  .modal-animation-breath-timer {
    font-size: 1.5rem;
  }
  
  .modal-animation-ready {
    font-size: 1rem;
    padding: 0.5rem;
  }
  
  .modal-messages-window {
    padding: var(--space-md);
  }
  
  .modal-messages-actions {
    flex-direction: column;
  }
  
  .modal-messages-button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 425px) {
  .modal-messages-actions {
    flex-direction: column;
  }
  
  .modal-messages-button {
    width: 100%;
  }
}
