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

body {
  height: 100vh;
  overflow: hidden;
  font-family: Georgia, serif;
  background:
    radial-gradient(circle at top, rgba(255, 218, 170, 0.18), transparent 35%),
    radial-gradient(circle, #4c2d23, #150907);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* LOCK */

.lock-screen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(255, 205, 155, 0.20), transparent 35%),
    radial-gradient(circle, #5b3026, #120706);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.diary-cover-lock {
  width: 380px;
  height: 540px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 25%),
    linear-gradient(135deg, #7d3f2a, #33150e);
  border: 5px solid #1e0d08;
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.75);
  text-align: center;
  padding: 55px 35px;
  color: #f8d99b;
  position: relative;
}

.diary-cover-lock::before {
  content: "";
  position: absolute;
  top: 0;
  left: 68px;
  width: 30px;
  height: 100%;
  background: rgba(255,255,255,0.08);
}

.lock-icon {
  font-size: 80px;
  margin-bottom: 25px;
}

.diary-cover-lock h1 {
  font-size: 34px;
  margin-bottom: 12px;
}

.diary-cover-lock p {
  margin-bottom: 20px;
}

.diary-cover-lock input {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  text-align: center;
  outline: none;
  margin-bottom: 15px;
}

.diary-cover-lock button,
.controls button {
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: #d7a84f;
  color: #241008;
  font-weight: bold;
  cursor: pointer;
}

.hint-text {
  margin-top: 15px;
  font-size: 15px;
  opacity: 0.75;
}

#errorText {
  margin-top: 15px;
  color: #ffb6b6;
}

/* APP */

.hidden {
  display: none;
}

.diary-app {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  perspective: 2400px;
}

.book-wrapper {
  transform: translateX(170px);
}

.book {
  position: relative;
  width: 450px;
  height: 640px;
  transition: transform 0.8s ease;
  transform-style: preserve-3d;
}

.book.opened {
  transform: translateX(225px);
}

.book-cover,
.back-cover {
  position: absolute;
  width: 450px;
  height: 640px;
  border-radius: 0 20px 20px 0;
  transform-origin: left;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.34), transparent 18%),
    linear-gradient(135deg, #7b3f2a, #2e120c);
  box-shadow: 0 24px 80px rgba(0,0,0,0.70);
}

.book-cover {
  z-index: 200;
  color: #f8d99b;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 18px solid #241008;
  transition: transform 1.05s ease;
  text-align: center;
  padding: 35px;
}

.book-cover h1 {
  font-size: 38px;
}

.book-cover p {
  margin-top: 16px;
  font-size: 18px;
}

.book-cover.flipped {
  transform: rotateY(-180deg);
  z-index: 1;
}

.back-cover {
  z-index: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #f8d99b;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.34), transparent 18%),
    linear-gradient(135deg, #5d2c1d, #241008);
}

.back-cover h2 {
  font-size: 34px;
}

/* PAPERS */

.paper {
  position: absolute;
  width: 450px;
  height: 640px;
  top: 0;
  left: 0;
  perspective: 2400px;
  transform-origin: left;
  transform-style: preserve-3d;
  transition: transform 1.05s ease;
}

.paper.flipped {
  transform: rotateY(-180deg);
}

.front,
.back {
  position: absolute;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.14), transparent 13%),
    #f5e5c8;
  border-radius: 0 16px 16px 0;
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow:
    inset 0 0 32px rgba(91, 58, 24, 0.18),
    0 8px 18px rgba(0,0,0,0.14);
}

.back {
  transform: rotateY(180deg);
  background:
    linear-gradient(270deg, rgba(0,0,0,0.12), transparent 13%),
    #f8e8cc;
}

.content {
  width: 100%;
  height: 100%;
  padding: 42px;
  position: relative;
}

.text-page::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(90, 50, 25, 0.18);
  border-radius: 12px;
  pointer-events: none;
}

.text-page h2 {
  color: #4a2a19;
  font-size: 30px;
  margin-bottom: 18px;
}

.text-page p {
  color: #4a2a19;
  font-size: 18px;
  line-height: 1.55;
  white-space: pre-line;
}

.signature {
  position: absolute;
  right: 42px;
  bottom: 35px;
  font-size: 20px;
  color: #5a2f1c;
  font-style: italic;
}

.image-page {
  display: flex;
  justify-content: center;
  align-items: center;
}

.photo-frame {
  width: 86%;
  min-height: 72%;
  background: #fff8e9;
  padding: 16px 16px 48px;
  transform: rotate(-2deg);
  box-shadow: 0 20px 38px rgba(0,0,0,0.35);
  display: flex;
  justify-content: center;
  align-items: center;
}

.photo-frame img {
  max-width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: 4px;
}

.blank-photo {
  color: #5a2f1c;
  font-size: 22px;
  text-align: center;
  opacity: 0.65;
}

.controls {
  margin-top: 32px;
  display: flex;
  gap: 20px;
}

.controls button {
  min-width: 125px;
  font-size: 15px;
}

@media (max-width: 900px) {
  .book-wrapper {
    transform: scale(0.72) translateX(130px);
  }

  .controls {
    margin-top: -40px;
  }
}

/* ===== MOBILE FIX ===== */

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  .lock-book,
  .diary-cover-lock {
    width: 86vw !important;
    height: 70vh !important;
    max-height: 560px;
    padding: 45px 24px !important;
  }

  .lock-icon {
    font-size: 64px !important;
  }

  .lock-book h1,
  .diary-cover-lock h1 {
    font-size: 34px !important;
  }

  .lock-book input,
  .diary-cover-lock input {
    font-size: 22px !important;
    padding: 18px !important;
  }

  .diary-app {
    justify-content: flex-start !important;
    padding-top: 20px;
  }

  .book-wrapper {
    transform: none !important;
    width: 100vw;
    height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .book {
    width: 92vw !important;
    height: 62vh !important;
    transform: none !important;
  }

  .book.opened {
    transform: none !important;
  }

  .book-cover,
  .back-cover,
  .paper {
    width: 46vw !important;
    height: 62vh !important;
  }

  .book-cover,
  .back-cover,
  .paper {
    left: 46vw !important;
  }

  .front,
  .back {
    width: 100% !important;
    height: 100% !important;
  }

  .content {
    padding: 22px !important;
  }

  .text-page h2 {
    font-size: 24px !important;
    margin-bottom: 14px !important;
  }

  .text-page p {
    font-size: 15px !important;
    line-height: 1.35 !important;
  }

  .signature {
    font-size: 17px !important;
    right: 22px !important;
    bottom: 18px !important;
  }

  .photo-frame {
    width: 88% !important;
    min-height: 55% !important;
    padding: 10px 10px 32px !important;
  }

  .photo-frame img {
    max-height: 38vh !important;
  }

  .blank-photo {
    font-size: 16px !important;
  }

  .controls {
    margin-top: 18px !important;
    gap: 18px !important;
  }

  .controls button {
    min-width: 120px !important;
    padding: 15px 20px !important;
    font-size: 16px !important;
  }
}


/* ===== MOBILE TEXT FIX ===== */

@media (max-width: 768px) {
  .content {
    padding: 24px 18px 55px !important;
  }

  .text-page {
    overflow-y: auto !important;
  }

  .text-page h2 {
    font-size: 28px !important;
    line-height: 1.05 !important;
    margin-bottom: 16px !important;
  }

  .text-page p {
    font-size: 16px !important;
    line-height: 1.28 !important;
    font-weight: 500 !important;
    padding-bottom: 40px !important;
  }

  .signature {
    position: absolute !important;
    right: 22px !important;
    bottom: 16px !important;
    font-size: 18px !important;
    background: rgba(245, 229, 200, 0.85);
    padding-left: 8px;
  }

  .text-page::before {
    inset: 16px !important;
  }
}

@media (max-width: 420px) {
  .text-page h2 {
    font-size: 25px !important;
  }

  .text-page p {
    font-size: 14px !important;
    line-height: 1.22 !important;
  }

  .signature {
    font-size: 16px !important;
  }
}

/* ===== CLEAN BLANK PHOTO PAGES + AMY MOBILE TEXT FIX ===== */

.blank-photo {
  color: transparent !important;
  font-size: 0 !important;
}

.blank-photo::before,
.blank-photo::after {
  content: "" !important;
}

@media (max-width: 768px) {
  .amy-page .text-page p {
    font-size: 13px !important;
    line-height: 1.18 !important;
    padding-bottom: 25px !important;
  }

  .amy-page .text-page h2 {
    font-size: 24px !important;
    margin-bottom: 10px !important;
  }

  .amy-page .signature {
    font-size: 15px !important;
  }
}
