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

html {
  font-size: 16px;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: #ffffff;
  color: #333;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  line-height: 1.6;
}

/* Main container */
.container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* View states */
.view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.view.hidden {
  display: none;
}

.view.fading-out {
  opacity: 0;
}

.view.fading-in {
  opacity: 0;
}

/* Input view */
#fortune-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

#user-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 15px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f9f9f9;
  color: #333;
  resize: none;
  overflow: hidden;
  min-height: 40px;
  line-height: 1.5;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 15px;
}

#user-input::placeholder {
  color: #999;
}

#user-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

#submit-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  padding: 8px 16px;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  color: white;
  border: 1px solid #000000;
  border-radius: 20px;
  cursor: pointer;
  width: 40%;
  min-width: 150px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2),
              0 0 0 1px rgba(0, 0, 0, 0.1);
  position: relative;
}

#submit-btn::after {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  pointer-events: none;
}

#submit-btn:hover {
  background: linear-gradient(to bottom, #4a4a4a, #3a3a3a);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(0, 0, 0, 0.1);
}

#submit-btn:active {
  transform: translateY(0);
}

#submit-btn:disabled {
  background: linear-gradient(to bottom, #999, #888);
  cursor: not-allowed;
  transform: none;
  opacity: 0.6;
}

/* Thinking view */
#thinking-view {
  min-height: 200px;
  justify-content: center;
}

#thinking-text {
  font-size: 1.25rem;
  font-style: italic;
  color: #555;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Fortune view */
#fortune-view {
  min-height: 200px;
  justify-content: center;
}

#fortune-container {
  width: 100%;
  max-width: 100%;
  padding: 2rem 1rem;
}

#fortune-text {
  font-size: 1.125rem;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
  color: #1a1a1a;
}

#fortune-actions {
  margin-top: 2.5rem;
  display: flex;
  gap: 2rem;
  opacity: 0;
  animation: fadeIn 0.5s ease 0.8s forwards;
}

.action-link {
  font-family: inherit;
  font-size: 0.9rem;
  color: #888;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s ease;
}

.action-link:hover {
  color: #1a1a1a;
}

/* Error view */
#error-view {
  min-height: 200px;
  justify-content: center;
  text-align: center;
}

#error-text {
  font-size: 1.125rem;
  color: #555;
  margin-bottom: 1.5rem;
  font-style: italic;
}

/* Fade animation */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  body {
    padding: 1.5rem 1rem;
  }

  #user-input {
    font-size: 14px;
    padding: 10px 15px;
  }

  #submit-btn {
    font-size: 14px;
    padding: 8px 16px;
    width: 40%;
    min-width: 120px;
  }

  #fortune-text {
    font-size: 1rem;
    line-height: 1.6;
  }

  #fortune-container {
    padding: 1.5rem 0.5rem;
  }

  #thinking-text {
    font-size: 1.125rem;
  }
}

@media (min-width: 768px) {
  body {
    padding: 3rem 2rem;
  }

  .container {
    max-width: 650px;
  }

  #fortune-text {
    font-size: 1.25rem;
  }

  #fortune-container {
    padding: 2.5rem 2rem;
  }
}

/* For image capture - hidden element used during save */
#capture-container {
  position: absolute;
  left: -9999px;
  top: -9999px;
  background: #ffffff;
  padding: 3rem;
  width: 600px;
}

#capture-container p {
  font-family: 'Roboto', sans-serif;
  font-size: 1.125rem;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
  color: #333;
}
