:root{
  --bg1:#ffd1e8;
  --bg2:#ffb6d9;
  --pink:#ff4fa3;
  --pink2:#ff7bbf;
  --paper:#fff6fb;
  --ink:#7a2450;
  --shadow: 0 18px 45px rgba(255, 79, 163, .25);
}

*{ box-sizing:border-box; }
body{
  margin:0;
  min-height:100vh;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% 10%, rgba(255,255,255,.7), transparent 55%),
    radial-gradient(900px 500px at 80% 30%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  overflow:hidden;
  display:grid;
  place-items:center;
  padding:24px;
}

body.letter-page{
  overflow:auto;
  display:block;
}

.strawberry-field{
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.9;
}

.strawberry{
  position:absolute;
  font-size:22px;
  filter: drop-shadow(0 8px 12px rgba(255,79,163,.18));
  animation: floatDown linear infinite;
  will-change: transform;
}

@keyframes floatDown{
  from{ transform: translateY(-120px) rotate(0deg); }
  to{ transform: translateY(calc(100vh + 140px)) rotate(360deg); }
}

.wrap{
  width:min(860px, 96vw);
  display:grid;
  gap:18px;
  justify-items:center;
  text-align:center;
  position:relative;
  z-index:2;
}

h1{
  margin:0;
  font-weight:800;
  letter-spacing:.2px;
  color:#8a1f53;
  text-shadow: 0 8px 18px rgba(255,255,255,.65);
}

.subtitle{
  margin:0;
  opacity:.85;
}

.envelope{
  width:min(520px, 92vw);
  height:320px;
  position:relative;
  border-radius:22px;
  background: linear-gradient(180deg, #ffd8ec, #ffc0de);
  box-shadow: var(--shadow);
  border: 2px solid rgba(255,79,163,.25);
  overflow:hidden;
  transform: translateZ(0);
  perspective: 900px;
}

.envelope.opening{
  overflow: visible;
}

.env-back{
  position:absolute;
  inset:0;
  background:
    radial-gradient(600px 240px at 50% 20%, rgba(255,255,255,.7), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,0));
  z-index: 1;
}

.flap{
  position:absolute;
  left:0;
  right:0;
  top:0;
  height:58%;
  background: linear-gradient(180deg, #ff9fcc, #ff6bb6);
  transform-origin: top center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: transform 900ms cubic-bezier(.2,.9,.15,1);
  border-bottom: 2px solid rgba(255,255,255,.35);
  z-index: 6;
}

.front{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  height:58%;
  background: linear-gradient(180deg, #ffc4e1, #ff9fd0);
  clip-path: polygon(0 0, 50% 70%, 100% 0, 100% 100%, 0 100%);
  border-top: 2px solid rgba(255,255,255,.35);
  z-index: 5;
}

.seal{
  position:absolute;
  left:50%;
  top:55%;
  transform: translate(-50%, -50%);
  width:72px;
  height:72px;
  border-radius:999px;
  background: radial-gradient(circle at 30% 25%, #fff, #ffd2ea 35%, #ff5aa9 75%);
  border: 2px solid rgba(255,255,255,.55);
  box-shadow: 0 14px 30px rgba(255, 79, 163, .28);
  display:grid;
  place-items:center;
  font-size:30px;
  user-select:none;
  z-index: 7;
}

.letter{
  position:absolute;
  left:50%;
  top:56%;
  width: calc(100% - 40px);
  height: calc(100% - 60px);
  background: var(--paper);
  border-radius:18px;
  border: 2px solid rgba(255,79,163,.18);
  box-shadow: 0 16px 40px rgba(122,36,80,.12);
  padding: 22px 28px 110px 28px;
  text-align:left;
  opacity:0;
  transform-origin: center center;
  transform: translate(-50%, -35%) scale(.96);
  transition:
    opacity 700ms ease,
    transform 900ms cubic-bezier(.2,.9,.15,1);
  overflow:auto;
  z-index: 2;
}

.top-gif{
  float:right;
  width:180px;
  height:auto;
  border-radius:14px;
  margin: -80px -10px 10px 12px;
  pointer-events:none;
  filter: drop-shadow(0 12px 20px rgba(255,79,163,.22));
}

.opening .flap{
  transform: rotateX(180deg);
  z-index: 2;
}

.opening .letter{
  opacity: 1;
  transform: translate(-50%, -95%) scale(1);
  z-index: 8;
}

.letter .topline{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.badge{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(255,79,163,.12);
  border: 1px solid rgba(255,79,163,.18);
  font-weight:650;
}

.badge-gif{
  width:34px;
  height:34px;
  object-fit:contain;
  border-radius:10px;
  margin-left:6px;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 14px rgba(255,79,163,.18));
}

.badge-gif-solo{
  width:46px;
  height:46px;
  margin-left:0;
}

.main-gif{
  display:block;
  width:min(320px, 100%);
  height:auto;
  margin: 14px auto 0;
  border-radius: 18px;
  filter: drop-shadow(0 16px 24px rgba(255,79,163,.22));
}

.letter h2{
  margin:6px 0 10px;
  font-size:22px;
}

.msg{
  margin:0;
  line-height:1.55;
  font-size:16px;
  white-space:pre-wrap;
}

.sig{
  margin-top:14px;
  font-weight:700;
  color:#8a1f53;
}

.corner-gif{
  position:absolute;
  right:-14px;
  bottom:-14px;
  width:240px;
  max-width: 52%;
  height:auto;
  border-radius:14px;
  opacity:.98;
  pointer-events:none;
  filter: drop-shadow(0 10px 18px rgba(255,79,163,.22));
}

.controls{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
}

button{
  appearance:none;
  border:0;
  cursor:pointer;
  padding:12px 16px;
  border-radius:999px;
  font-weight:750;
  color:white;
  background: linear-gradient(180deg, var(--pink2), var(--pink));
  box-shadow: 0 14px 30px rgba(255,79,163,.25);
  transition: transform 140ms ease, filter 140ms ease;
}

button:hover{
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:active{
  transform: translateY(1px);
}

.secondary{
  background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(255,255,255,.55));
  color:#8a1f53;
  border: 1px solid rgba(255,79,163,.25);
}

.open .flap{ transform: rotateX(180deg); }
.open .letter{
  opacity:1;
  transform: translate(-50%, -50%) scale(1);
}

.sparkle{
  position:absolute;
  inset:-40px;
  background: radial-gradient(500px 200px at 50% 10%, rgba(255,255,255,.65), transparent 60%);
  opacity:.6;
  pointer-events:none;
}

.page-wrap{
  width:min(920px, 96vw);
  margin: 0 auto;
  padding: 24px 0 48px;
  position:relative;
  z-index:2;
}

.page-header{
  display:flex;
  justify-content:flex-start;
  padding: 6px 0 14px;
}

.back-link{
  display:inline-flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  color:#8a1f53;
  font-weight:750;
  padding:10px 14px;
  border-radius:999px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,79,163,.20);
  box-shadow: 0 12px 26px rgba(255,79,163,.14);
}

.paper{
  position:relative;
  border-radius: 18px;
  border: 2px solid rgba(255,79,163,.18);
  box-shadow: 0 18px 50px rgba(122,36,80,.14);
  padding: 26px 46px 120px 60px;
  background:
    linear-gradient(90deg, rgba(255,79,163,.22) 0 3px, transparent 3px 100%),
    linear-gradient(90deg, rgba(255,79,163,.10) 0 1px, transparent 1px 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(120, 180, 255, .00) 0px,
      rgba(120, 180, 255, .00) 22px,
      rgba(120, 180, 255, .38) 22px,
      rgba(120, 180, 255, .38) 23px
    ),
    var(--paper);
  background-size: 100% 100%, 100% 100%, 100% 23px, 100% 100%;
  background-position:
    40px 0,
    60px 0,
    0 0,
    0 0;
  overflow:hidden;
}

.paper::before{
  content:"";
  position:absolute;
  left: 10px;
  top: 18px;
  bottom: 18px;
  width: 38px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 24px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 74px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 124px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 174px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 224px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 274px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px),
    radial-gradient(circle at 50% 324px, rgba(255,255,255,.95) 0 6px, rgba(255,79,163,.18) 7px 8px, transparent 9px);
  opacity:.9;
  pointer-events:none;
}

.paper-topline{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.paper-title{
  margin: 8px 0 10px;
  font-size: 28px;
  letter-spacing:.2px;
}

.paper-msg{
  margin:0;
  line-height:1.7;
  font-size: 18px;
  white-space:pre-wrap;
}

.paper-sig{
  margin-top:18px;
  font-weight:800;
  color:#8a1f53;
  font-size: 18px;
}

@media (max-width: 420px){
  body{
    padding: 16px;
    overflow-x: hidden;
  }
  
  .envelope{
    width: min(340px, 94vw);
    height: 220px;
  }
  
  .letter{
    width: calc(100% - 32px);
    height: calc(100% - 40px);
    padding: 14px 14px 70px;
    font-size: 14px;
  }
  
  .letter h2{
    font-size: 18px;
    margin: 4px 0 6px;
  }
  
  .msg{
    font-size: 13px;
    line-height: 1.5;
  }
  
  .sig{
    font-size: 13px;
    margin-top: 10px;
  }
  
  .topline{
    gap: 6px;
  }
  
  .badge{
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .top-gif{
    width: 100px;
    margin: -30px -6px 8px 8px;
    border-radius: 10px;
  }
  
  .corner-gif{
    width: 140px;
    right: -8px;
    bottom: -8px;
  }
  
  .seal{
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
  
  .controls{
    gap: 8px;
  }
  
  button{
    padding: 10px 14px;
    font-size: 14px;
  }
  
  h1{
    font-size: 22px;
  }
  
  .subtitle{
    font-size: 14px;
  }
  
  .wrap{
    gap: 12px;
  }
  
  .page-wrap{
    padding: 16px 0 32px;
  }
  
  .paper{
    padding: 18px 18px 80px 58px;
    background-position: 38px 0, 58px 0, 0 0, 0 0;
  }
  
  .paper::before{
    width: 28px;
    left: 12px;
    background:
      radial-gradient(circle at 50% 18px, rgba(255,255,255,.95) 0 4px, rgba(255,79,163,.18) 5px 6px, transparent 7px),
      radial-gradient(circle at 50% 58px, rgba(255,255,255,.95) 0 4px, rgba(255,79,163,.18) 5px 6px, transparent 7px),
      radial-gradient(circle at 50% 98px, rgba(255,255,255,.95) 0 4px, rgba(255,79,163,.18) 5px 6px, transparent 7px),
      radial-gradient(circle at 50% 138px, rgba(255,255,255,.95) 0 4px, rgba(255,79,163,.18) 5px 6px, transparent 7px),
      radial-gradient(circle at 50% 178px, rgba(255,255,255,.95) 0 4px, rgba(255,79,163,.18) 5px 6px, transparent 7px);
  }
  
  .paper-title{
    font-size: 22px;
  }
  
  .paper-msg{
    font-size: 15px;
    line-height: 1.6;
  }
  
  .paper-sig{
    font-size: 15px;
  }
  
  .back-link{
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .strawberry{
    font-size: 16px;
  }
}

@media (max-width: 360px){
  .envelope{
    width: min(300px, 96vw);
    height: 200px;
  }
  
  .letter{
    padding: 12px 12px 60px;
  }
  
  .top-gif{
    width: 80px;
    margin: -25px -4px 6px 6px;
  }
  
  .corner-gif{
    width: 110px;
  }
  
  .paper{
    padding: 16px 16px 70px 48px;
    background-position: 30px 0, 48px 0, 0 0, 0 0;
  }
}

