/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", sans-serif;
  background: linear-gradient(135deg, #1a2332 0%, #0f1419 50%, #0a0e14 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #a8c5d8;
  position: relative;
}

/* Starry sky background */
.stars-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 4px #fff;
}

.star-twinkle {
  animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
  }
}

/* Ensure content is above stars */
.counter-container,
.breathing-container,
.reset-button {
  position: relative;
  z-index: 10;
}

/* App Title */
.app-title {
  position: fixed;
  top: 2rem;
  left: 2rem;
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #7ba7bc;
  opacity: 0;
  animation: fadeIn 2s ease-out forwards;
  z-index: 10;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 0.8;
    transform: translateX(0);
  }
}

/* Counter in top-right corner */
.counter-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  text-align: center;
  background: rgba(26, 35, 50, 0.6);
  backdrop-filter: blur(10px);
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(168, 197, 216, 0.1);
}

.counter-label {
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7ba7bc;
  margin-bottom: 0.25rem;
}

.counter-value {
  font-size: 2rem;
  font-weight: 600;
  color: #a8c5d8;
}

/* Main breathing container */
.breathing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8rem;
}

/* The animated orb */
.orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6b9ac4, #4a7ba7);
  box-shadow: 0 0 40px rgba(106, 154, 196, 0.6),
    0 0 80px rgba(106, 154, 196, 0.3), 0 0 120px rgba(106, 154, 196, 0.15),
    inset 0 0 30px rgba(168, 197, 216, 0.2);
  transition: all ease-in-out;
  will-change: transform;
}

.orb.inhale {
  transform: scale(3);
  transition-duration: 4s;
}

.orb.hold {
  transform: scale(3);
  transition-duration: 0.5s;
}

.orb.exhale {
  transform: scale(1);
  transition-duration: 8s;
}

/* Instruction text */
.instruction-text {
  font-size: 1.5rem;
  font-weight: 300;
  color: #a8c5d8;
  text-align: center;
  letter-spacing: 0.05em;
  min-height: 2rem;
  opacity: 0.9;
}

/* Controls container centered at bottom */
.controls-container {
  position: fixed;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  z-index: 10;
}

/* Independent Info Button in bottom-right */
.info-button-corner {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10;
}

/* Common button styles */
.reset-button {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #a8c5d8;
  background: rgba(26, 35, 50, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(168, 197, 216, 0.2);
  border-radius: 3rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  min-width: 140px;
}

.reset-button.pulse {
  background: rgba(106, 154, 196, 0.2);
  border-color: rgba(168, 197, 216, 0.4);
  animation: buttonPulse 2s infinite;
}

@keyframes buttonPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(168, 197, 216, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(168, 197, 216, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(168, 197, 216, 0);
  }
}

.icon-button {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a8c5d8;
  background: rgba(26, 35, 50, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(168, 197, 216, 0.2);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 56px;
  height: 56px;
}

.icon-button svg {
  width: 32px;
  height: 32px;
}

.reset-button:hover,
.icon-button:hover {
  background: rgba(26, 35, 50, 0.8);
  border-color: rgba(168, 197, 216, 0.3);
  box-shadow: 0 6px 25px rgba(106, 154, 196, 0.4);
  transform: translateY(-2px);
  color: #fff;
}

.reset-button:active,
.icon-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(26, 35, 50, 0.95);
  border: 1px solid rgba(168, 197, 216, 0.2);
  padding: 2.5rem;
  border-radius: 1.5rem;
  max-width: 500px;
  width: 90%;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-content h2 {
  color: #7ba7bc;
  margin-bottom: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  font-size: 1.5rem;
}

.modal-intro {
  color: #a8c5d8;
  line-height: 1.5;
  font-size: 1rem;
  font-weight: 300;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.phase-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.phase-item {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.phase-number {
  background: rgba(123, 167, 188, 0.1);
  color: #7ba7bc;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  min-width: 3.5rem;
  text-align: center;
  border: 1px solid rgba(123, 167, 188, 0.2);
}

.phase-details h3 {
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.phase-details p {
  color: #a8c5d8;
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 300;
  opacity: 0.8;
  margin: 0;
}

.modal-tip {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(168, 197, 216, 0.1);
  color: #7ba7bc;
  font-size: 0.95rem;
  text-align: center;
  font-weight: 300;
  opacity: 0.9;
}

.close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #5a7c8c;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.5rem;
  transition: color 0.2s ease;
}

.close-button:hover {
  color: #a8c5d8;
}

/* Accessibility: Focus styles */
button:focus-visible {
  outline: 2px solid #7ba7bc;
  outline-offset: 4px;
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .orb,
  .orb.inhale,
  .orb.hold,
  .orb.exhale,
  .star-twinkle,
  .app-title,
  .reset-button,
  .icon-button,
  .modal-overlay,
  .modal-content {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  .orb {
    /* Keep a static size that is visible but not moving */
    transform: scale(1.5) !important;
  }
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .app-title {
    top: 1.5rem;
    font-size: 1rem;
  }

  .counter-container {
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
  }

  .counter-label {
    font-size: 0.75rem;
  }

  .counter-value {
    font-size: 1.5rem;
  }

  .orb {
    width: 90px;
    height: 90px;
  }

  .instruction-text {
    font-size: 1.25rem;
  }

  .controls-container {
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    right: auto;
  }

  .reset-button {
    padding: 0.8rem 2rem;
    font-size: 1rem;
  }

  .icon-button {
    padding: 0.625rem;
    width: 42px;
    height: 42px;
  }

  .icon-button svg {
    width: 24px;
    height: 24px;
  }

  .modal-content {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .orb {
    width: 90px;
    height: 90px;
  }

  .orb.inhale,
  .orb.hold {
    transform: scale(3);
  }
}
