* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #000000;
  color: #ffffff;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  height: 100vh;
  position: relative;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Welcome Screen */
#welcome-screen {
  gap: 2rem;
}

.logo-container {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo {
  width: 140px;
  height: 40px;
  color: #ffffff;
  opacity: 0.9;
}

.logo-circle {
  animation: logoBreathe 10s ease-in-out infinite;
  transform-origin: center;
}

@keyframes logoBreathe {
  0%, 100% {
    transform: translate(12px, 20px) scale(0.96);
  }
  50% {
    transform: translate(12px, 20px) scale(1.0);
  }
}

.phrase-container {
  margin-bottom: 1rem;
}

.phrase {
  font-size: clamp(1.2rem, 5vw, 2rem);
  font-weight: 300;
  opacity: 0.8;
  animation: fadeIn 0.5s ease;
}

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

.duration-selector h2,
.display-mode-selector h3 {
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 1rem;
  background: linear-gradient(
    90deg,
    #40ffaa,
    #4079ff,
    #40ffaa,
    #4079ff,
    #40ffaa
  );
  background-size: 300% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: gradientText 7.5s ease infinite;
}

@keyframes gradientText {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.duration-buttons,
.mode-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.duration-btn,
.mode-btn {
  padding: 0.8rem 1.5rem;
  border: 2px solid #333;
  background: transparent;
  color: #ffffff;
  border-radius: 24px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 80px;
  position: relative;
  overflow: hidden;
}

.duration-btn::before,
.mode-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.duration-btn:hover::before,
.mode-btn:hover::before {
  left: 100%;
}

.duration-btn:hover,
.mode-btn:hover {
  border-color: #ffffff;
  transform: translateY(-2px);
  animation: borderGlow 2s ease infinite;
}

@keyframes borderGlow {
  0%, 100% {
    border-color: #ffffff;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
  }
  25% {
    border-color: #4a90e2;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
  }
  50% {
    border-color: #7b68ee;
    box-shadow: 0 0 20px rgba(123, 104, 238, 0.6);
  }
  75% {
    border-color: #4a90e2;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
  }
}

.duration-btn.active,
.mode-btn.active {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  position: relative;
  overflow: hidden;
}

.duration-btn.active::before,
.mode-btn.active::before {
  background: linear-gradient(90deg, transparent, rgba(74, 144, 226, 0.12), rgba(123, 104, 238, 0.12), transparent);
}

.duration-btn.active:hover,
.mode-btn.active:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2), 0 0 12px rgba(123, 104, 238, 0.15);
  animation: borderGlowLight 2s ease infinite;
}

.mode-descriptions {
  margin-top: 1rem;
  text-align: center;
}

.mode-desc {
  font-size: 0.9rem;
  opacity: 0.7;
  margin-bottom: 0.5rem;
  display: none;
}

.mode-desc.active {
  display: block;
}

.custom-duration {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
}

.custom-duration input {
  padding: 0.8rem;
  border: 2px solid #333;
  background: transparent;
  color: #ffffff;
  border-radius: 20px;
  font-size: 1rem;
  width: 120px;
  text-align: center;
}

.custom-duration input:focus {
  outline: none;
  border-color: #ffffff;
}

.custom-duration button {
  padding: 0.8rem 1.5rem;
  border: 2px solid #ffffff;
  background: #ffffff;
  color: #000000;
  border-radius: 24px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.custom-duration button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(74, 144, 226, 0.15), rgba(123, 104, 238, 0.15), transparent);
  transition: left 0.6s ease;
}

.custom-duration button:hover::before {
  left: 100%;
}

.custom-duration button:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2), 0 0 12px rgba(123, 104, 238, 0.15);
  animation: borderGlowLight 2s ease infinite;
}

.hidden {
  display: none !important;
}

.start-btn {
  padding: 1.2rem 3rem;
  border: 2px solid #ffffff;
  background: #ffffff;
  color: #000000;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}

.start-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(74, 144, 226, 0.15), rgba(123, 104, 238, 0.15), transparent);
  transition: left 0.6s ease;
}

.start-btn:hover::before {
  left: 100%;
}

.start-btn:hover {
  background: #f5f5f5;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(74, 144, 226, 0.25), 0 0 20px rgba(123, 104, 238, 0.15);
  animation: borderGlowLight 2s ease infinite;
}

@keyframes borderGlowLight {
  0%, 100% {
    border-color: #ffffff;
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.25), 0 0 20px rgba(123, 104, 238, 0.15);
  }
  25% {
    border-color: #4a90e2;
    box-shadow: 0 8px 30px rgba(74, 144, 226, 0.4), 0 0 25px rgba(74, 144, 226, 0.3);
  }
  50% {
    border-color: #7b68ee;
    box-shadow: 0 8px 35px rgba(123, 104, 238, 0.5), 0 0 30px rgba(123, 104, 238, 0.4);
  }
  75% {
    border-color: #4a90e2;
    box-shadow: 0 8px 30px rgba(74, 144, 226, 0.4), 0 0 25px rgba(74, 144, 226, 0.3);
  }
}

.fullscreen-btn {
  padding: 0.8rem 2rem;
  border: 2px solid #333;
  background: transparent;
  color: #ffffff;
  border-radius: 24px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}

.fullscreen-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.fullscreen-btn:hover::before {
  left: 100%;
}

.fullscreen-btn:hover {
  border-color: #ffffff;
  animation: borderGlow 2s ease infinite;
}

/* Timer Screen */
#timer-screen {
  background: #000000;
  cursor: pointer;
}

.timer-display {
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.timer-display.ghost {
  opacity: 0.1;
}

.dot-display {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.breathing-square {
  --square-size: 200px;
  --dot-size: 16px;
  
  width: var(--square-size);
  height: var(--square-size);
  border: 2px solid rgba(255, 255, 255, 0.3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.breathing-indicator {
  position: absolute;
  width: var(--dot-size);
  height: var(--dot-size);
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.8;
  /* Start at bottom left corner */
  top: calc(var(--square-size) - var(--dot-size) / 2);
  left: calc(-1 * var(--dot-size) / 2);
  animation: breathingSquare 10s linear infinite;
  will-change: transform;
}

@keyframes breathingSquare {
  /* Start at bottom left corner - начало Inhale фазы */
  0% {
    transform: translate(0, 0);
  }
  /* Left edge - Inhale (moving up to top left corner) - 25% (2.5 seconds) */
  24.999% {
    transform: translate(0, calc(-1 * var(--square-size)));
  }
  25% {
    transform: translate(0, calc(-1 * var(--square-size)));
  }
  /* Top edge - Hold (moving right to top right corner) - 25% (2.5 seconds) */
  49.999% {
    transform: translate(var(--square-size), calc(-1 * var(--square-size)));
  }
  50% {
    transform: translate(var(--square-size), calc(-1 * var(--square-size)));
  }
  /* Right edge - Exhale (moving down to bottom right corner) - 25% (2.5 seconds) */
  74.999% {
    transform: translate(var(--square-size), 0);
  }
  75% {
    transform: translate(var(--square-size), 0);
  }
  /* Bottom edge - Hold (moving left back to bottom left corner) - 25% (2.5 seconds) */
  100% {
    transform: translate(0, 0);
  }
}

.breathing-labels {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.breathing-labels span {
  position: absolute;
  font-size: 0.75rem;
  opacity: 0.5;
  font-weight: 300;
}

.label-top {
  top: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
}

.label-right {
  right: -2.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.label-bottom {
  bottom: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
}

.label-left {
  left: -3.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.touch-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
  animation: fadeInOut 2.5s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  15% { opacity: 0.6; }
  85% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* Completion Screen */
.completion-content {
  max-width: 400px;
}

.completion-content h2 {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 1rem;
  animation: fadeIn 0.5s ease;
}

.completion-content p {
  font-size: 1.2rem;
  opacity: 0.8;
  margin-bottom: 2rem;
  animation: fadeIn 0.5s ease 0.2s both;
}

.reflection-input {
  margin-bottom: 2rem;
  animation: fadeIn 0.5s ease 0.3s both;
}

.reflection-input textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.5rem;
  min-height: 80px;
}

.reflection-input textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

.reflection-input textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.btn-reflection {
  padding: 0.6rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 20px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-reflection:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.completion-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.5s ease 0.4s both;
}

.btn {
  padding: 1rem 2rem;
  border: 2px solid #ffffff;
  background: transparent;
  color: #ffffff;
  border-radius: 28px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  animation: borderGlow 2s ease infinite;
}

.completion-btn:hover {
  background: transparent;
  color: #ffffff;
}

/* Stats */
.stats-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  border: 2px solid #333;
  background: transparent;
  color: #ffffff;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.stats-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: transform 0.3s ease;
}

.stats-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.stats-btn:hover::before {
  width: 100%;
  height: 100%;
}

.stats-btn:hover {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  animation: borderGlow 2s ease infinite;
}

.stats-btn:hover svg {
  transform: scale(1.1);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #111;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.modal-content h3 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
}

.exit-to-site-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #ffffff;
  background: transparent;
  color: #ffffff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.exit-to-site-btn:hover {
  background: #ffffff;
  color: #000000;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.reflections-section {
  margin-top: 2rem;
  margin-bottom: 1.5rem;
  text-align: left;
  border-top: 1px solid #333;
  padding-top: 1.5rem;
}

.reflections-section h4 {
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 1rem;
  color: #ffffff;
  opacity: 0.9;
}

.reflections-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.reflections-list::-webkit-scrollbar {
  width: 6px;
}

.reflections-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.reflections-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.reflections-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.no-reflections {
  opacity: 0.6;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  font-style: italic;
}

.reflection-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  position: relative;
  transition: all 0.3s ease;
}

.reflection-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.reflection-date {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-bottom: 0.5rem;
  font-weight: 300;
}

.reflection-text {
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0.9;
  white-space: pre-wrap;
  word-break: break-word;
}

.delete-reflection {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-reflection:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 300;
  color: #ffffff;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 480px) {
  .screen {
    padding: 1rem;
  }
  
  .duration-buttons,
  .mode-buttons {
    gap: 0.3rem;
  }
  
  .duration-btn,
  .mode-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    min-width: 70px;
  }
  
  .start-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}
