/* --- Original Styles --- */
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background-color: #fff5f8;
  color: #ff6b81;
  display: flex;
  justify-content: center;
  align-items: center;
  /* ใช้ min-height เพื่อให้ scroll ได้ถ้าเนื้อหายาว */
  min-height: 100vh;
  /* เอา overflow: hidden ออก */
  /* overflow: hidden; */
  /* เพิ่ม padding ให้ body ป้องกันเนื้อหาชิดขอบจอ */
  padding: 10px;
  box-sizing: border-box; /* คำนวณ padding เข้าไปใน width/height */
}

.container {
  text-align: center;
  padding: 20px; /* Padding เริ่มต้น */
  width: 100%; /* ทำให้ container ใช้พื้นที่แนวนอนได้เต็มที่ (ตาม padding ของ body) */
  max-width: 600px; /* จำกัดความกว้างสูงสุดสำหรับจอใหญ่ */
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 8px 20px rgba(255, 107, 129, 0.2);
  animation: fadeIn 2s ease;
  box-sizing: border-box; /* คำนวณ padding เข้าไปใน width */
}

h1.fade-in {
  font-size: 2.5rem; /* ขนาดเริ่มต้น */
  margin-bottom: 0.5rem;
  animation: fadeInText 3s ease forwards;
}

.subtitle.slide-in {
  font-size: 1.1rem; /* ขนาดเริ่มต้น */
  margin-bottom: 20px;
  animation: slideIn 2s ease forwards;
}

.slideshow {
  margin-bottom: 20px; /* เพิ่มระยะห่างด้านล่างเล็กน้อย */
}

.slideshow img {
  width: 100%;
  max-height: 300px; /* ความสูงสูงสุดเริ่มต้น */
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: block; /* แก้ปัญหา space ใต้ภาพ */
}

.open-button {
  background-color: #ffb6c1;
  border: none;
  padding: 10px 20px; /* padding เริ่มต้น */
  border-radius: 20px;
  cursor: pointer;
  font-size: 1rem; /* ขนาด font เริ่มต้น */
  transition: background-color 0.3s ease, color 0.3s ease;
  margin-top: 15px; /* เพิ่มระยะห่างด้านบน */
}

.open-button:hover {
  background-color: #ff6b81;
  color: white;
}

.letter-content {
  margin-top: 20px;
  padding: 15px; /* padding เริ่มต้น */
  background-color: #ffeef3;
  border: 2px solid #ffb6c1;
  border-radius: 16px;
  animation: fadeInText 1s ease forwards;
  text-align: left; /* จัดข้อความในจดหมายชิดซ้าย */
  line-height: 1.6; /* เพิ่มระยะห่างระหว่างบรรทัดให้อ่านง่ายขึ้น */
  font-size: 1rem; /* ขนาด font เริ่มต้น */
}

.hidden {
  display: none;
}

.letter p {
    margin: 0; /* เอา margin ของ p ออก */
}

.letter strong {
    display: block; /* ทำให้ชื่อผู้ส่งขึ้นบรรทัดใหม่ */
    margin-top: 1em; /* เพิ่มระยะห่างบนชื่อผู้ส่ง */
}

/* --- Keyframe Animations (Keep as is) --- */
@keyframes fadeInText {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Responsive Adjustments --- */

/* Tablet devices (เช่น iPads แนวตั้ง) */
@media (max-width: 768px) {
  .container {
    padding: 15px;
    border-radius: 20px;
  }

  h1.fade-in {
    font-size: 2.2rem; /* ลดขนาด H1 */
  }

  .subtitle.slide-in {
    font-size: 1rem; /* ลดขนาด subtitle */
  }

  .slideshow img {
     max-height: 280px; /* ลดความสูงรูปภาพ */
     border-radius: 12px;
  }

  .letter-content {
    padding: 12px;
    font-size: 0.95rem; /* ลดขนาด font ในจดหมายเล็กน้อย */
  }
}

/* Mobile devices (เช่น iPhones, Android phones) */
@media (max-width: 480px) {
   body {
     /* จัดชิดบนแทนกลางแนวตั้งเมื่อเนื้อหายาว */
     align-items: flex-start;
     padding: 20px 10px; /* เพิ่ม padding บนล่าง */
   }

  .container {
    padding: 15px 10px; /* ลด padding ซ้ายขวา */
    border-radius: 16px;
  }

  h1.fade-in {
    font-size: 1.8rem; /* ลดขนาด H1 อีก */
  }

  .subtitle.slide-in {
    font-size: 0.9rem; /* ลดขนาด subtitle อีก */
    margin-bottom: 15px;
  }

  .slideshow img {
    max-height: 200px; /* ลดความสูงรูปภาพอีก */
    border-radius: 10px;
  }

  .open-button {
    padding: 12px 24px; /* เพิ่ม padding ให้กดง่ายขึ้น */
    font-size: 0.95rem;
  }

  .letter-content {
    padding: 10px;
    font-size: 0.9rem; /* ลดขนาด font ในจดหมายอีก */
    line-height: 1.5;
  }
}