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

body {
  font-family: "Sarabun", sans-serif;
  background: linear-gradient(135deg, #fef9f3 0%, #fdf2f8 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 600px;
  padding: 20px;
}

/* Screen Management */
.screen {
  display: none;
  animation: fadeIn 0.8s ease;
}

.screen.active {
  display: block;
}

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

/* Lock Screen */
#lock-screen {
  text-align: center;
  padding: 60px 20px;
}

.lock-content {
  background: white;
  border-radius: 25px;
  padding: 50px 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

#lock-screen h1 {
  font-family: "Playfair Display", serif;
  font-size: 1.8rem;
  color: #333;
  margin-bottom: 15px;
  font-weight: 400;
}

#pin-input {
  display: block;
  width: 150px;
  margin: 20px auto;
  padding: 15px;
  font-size: 1.5rem;
  text-align: center;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-family: "Sarabun", sans-serif;
  letter-spacing: 8px;
  transition: border-color 0.3s ease;
}

#pin-input:focus {
  outline: none;
  border-color: #e74c3c;
}

.error-text {
  color: #e74c3c;
  font-size: 0.9rem;
  margin-top: 15px;
  min-height: 20px;
}

/* Start Screen */
#start-screen {
  text-align: center;
  padding: 60px 20px;
}

.heart-icon {
  font-size: 80px;
  animation: heartbeat 1.5s ease-in-out infinite;
  margin-bottom: 30px;
}

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

#start-screen h1 {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  color: #333;
  margin-bottom: 15px;
  font-weight: 400;
}

.subtitle {
  color: #888;
  font-size: 1rem;
  margin-bottom: 40px;
}

.start-button {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  border: none;
  padding: 15px 50px;
  font-size: 1.1rem;
  border-radius: 50px;
  cursor: pointer;
  font-family: "Sarabun", sans-serif;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

/* Story Screen */
#story-screen {
  padding: 20px 0;
}

.story-container {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.image-container {
  width: 100%;
  height: 300px;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 25px;
  background: #f8f8f8;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: imageIn 0.5s ease;
}

@keyframes imageIn {
  from {
    opacity: 0;
    transform: scale(1.05);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.text-container {
  min-height: 120px;
  padding: 20px 0;
  position: relative;
}

.heart-small {
  font-size: 24px;
  margin-bottom: 15px;
}

.typewriter {
  font-size: 1.2rem;
  line-height: 1.8;
  color: #333;
  display: inline;
}

.cursor {
  display: inline-block;
  color: #e74c3c;
  animation: blink 0.8s infinite;
  font-weight: 300;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

.navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #f0f0f0;
}

#progress {
  color: #999;
  font-size: 0.9rem;
}

.next-button {
  background: none;
  border: 2px solid #e74c3c;
  color: #e74c3c;
  padding: 10px 25px;
  font-size: 1rem;
  border-radius: 25px;
  cursor: pointer;
  font-family: "Sarabun", sans-serif;
  transition: all 0.3s ease;
}

.next-button:hover {
  background: #e74c3c;
  color: white;
}

.next-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Final Screen */
#final-screen {
  text-align: center;
  padding: 40px 20px;
}

.final-content {
  background: white;
  border-radius: 25px;
  padding: 50px 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.hearts-animation {
  font-size: 30px;
  margin-bottom: 30px;
}

.hearts-animation span {
  display: inline-block;
  animation: float 2s ease-in-out infinite;
}

.hearts-animation span:nth-child(1) {
  animation-delay: 0s;
}
.hearts-animation span:nth-child(2) {
  animation-delay: 0.2s;
}
.hearts-animation span:nth-child(3) {
  animation-delay: 0.4s;
}
.hearts-animation span:nth-child(4) {
  animation-delay: 0.6s;
}
.hearts-animation span:nth-child(5) {
  animation-delay: 0.8s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.final-title {
  font-family: "Playfair Display", serif;
  font-size: 2.2rem;
  color: #e74c3c;
  font-weight: 400;
  margin-bottom: 5px;
}

.final-subtitle {
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  color: #333;
  font-weight: 400;
  font-style: italic;
  margin-bottom: 30px;
}

.names {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}

.name {
  font-size: 1.3rem;
  color: #333;
  font-weight: 500;
}

.heart-between {
  font-size: 24px;
  animation: heartbeat 1.5s ease-in-out infinite;
}

.final-message {
  font-size: 1.5rem;
  color: #e74c3c;
  margin-bottom: 30px;
}

.restart-button {
  background: none;
  border: 1px solid #ccc;
  color: #888;
  padding: 10px 25px;
  font-size: 0.9rem;
  border-radius: 25px;
  cursor: pointer;
  font-family: "Sarabun", sans-serif;
  transition: all 0.3s ease;
}

.restart-button:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* Responsive */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 10px;
  }

  /* Lock Screen Mobile */
  .lock-content {
    padding: 40px 20px;
  }

  #lock-screen h1 {
    font-size: 1.4rem;
  }

  #pin-input {
    width: 180px;
    padding: 18px;
    font-size: 1.8rem;
    letter-spacing: 10px;
    -webkit-text-security: disc;
  }

  /* Start Screen Mobile */
  #start-screen {
    padding: 40px 15px;
  }

  .heart-icon {
    font-size: 60px;
    margin-bottom: 20px;
  }

  #start-screen h1 {
    font-size: 1.6rem;
  }

  .subtitle {
    font-size: 0.95rem;
    margin-bottom: 30px;
  }

  .start-button {
    padding: 14px 40px;
    font-size: 1rem;
    width: 100%;
    max-width: 250px;
  }

  /* Story Screen Mobile */
  .story-container {
    padding: 20px;
    border-radius: 15px;
  }

  .image-container {
    height: 220px;
    margin-bottom: 20px;
    border-radius: 12px;
  }

  .text-container {
    min-height: 100px;
    padding: 15px 0;
  }

  .heart-small {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .typewriter {
    font-size: 1.05rem;
    line-height: 1.7;
  }

  .navigation {
    margin-top: 20px;
    padding-top: 15px;
  }

  #progress {
    font-size: 0.85rem;
  }

  .next-button {
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  /* Final Screen Mobile */
  #final-screen {
    padding: 30px 15px;
  }

  .final-content {
    padding: 40px 20px;
  }

  .final-title {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }

  .final-subtitle {
    font-size: 1.2rem;
    margin-bottom: 25px;
  }

  .restart-button {
    padding: 12px 30px;
  }
}

/* Extra small devices */
@media (max-width: 360px) {
  .heart-icon {
    font-size: 50px;
  }

  #start-screen h1 {
    font-size: 1.4rem;
  }

  .image-container {
    height: 180px;
  }

  .typewriter {
    font-size: 1rem;
  }

  .final-title {
    font-size: 1.4rem;
  }
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
  input[type="password"] {
    font-size: 16px;
  }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  body {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
