:root{
  --navy: #171B2E;
  --navy-deep: #0F1220;
  --paper: #FBF3E2;
  --gold: #C9A24B;
  --gold-bright: #E8C878;
  --wax: #8E2C3A;
  --ink: #2A2333;
  --muted: #8B90AC;
  --monkey: #8A5A34;
  --monkey-light: #C99361;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  min-height:100vh;
  background:
    radial-gradient(ellipse at 20% -10%, #262B47 0%, transparent 55%),
    radial-gradient(ellipse at 90% 110%, #1D2138 0%, transparent 50%),
    var(--navy);
  font-family:'Inter',sans-serif;
  color:var(--paper);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  position:relative;
  overflow-x:hidden;
}
body::before{
  content:'';
  position:fixed; inset:0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,.25), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,.2), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,.15), transparent),
    radial-gradient(1px 1px at 30% 85%, rgba(255,255,255,.2), transparent),
    radial-gradient(1.5px 1.5px at 90% 60%, rgba(255,255,255,.18), transparent);
  pointer-events:none; z-index:0;
}
.stage{ position:relative; z-index:1; width:100%; max-width:520px; }
.eyebrow{ font-size:12px; letter-spacing:.22em; text-transform:uppercase; color:var(--gold); text-align:center; margin-bottom:10px; font-weight:500; }
h1{ font-family:'Fraunces',serif; font-weight:600; font-size:clamp(28px,6vw,40px); text-align:center; margin:0 0 8px; }
.sub{ text-align:center; color:var(--muted); font-size:14.5px; margin:0 0 34px; line-height:1.5; }
.card{ background:rgba(255,255,255,.03); border:1px solid rgba(201,162,75,.25); border-radius:16px; padding:28px 24px; backdrop-filter:blur(6px); position:relative; }
label{ display:block; font-size:12.5px; color:var(--gold-bright); letter-spacing:.04em; margin-bottom:6px; margin-top:18px; font-weight:500; }
label:first-child{ margin-top:0; }
input[type=text], input[type=email], textarea{
  width:100%; background:rgba(0,0,0,.22); border:1px solid rgba(201,162,75,.3);
  border-radius:10px; padding:12px 14px; color:var(--paper); font-family:'Inter',sans-serif;
  font-size:15px; resize:vertical; outline:none; transition:border-color .15s ease, background .15s ease;
}
input:focus, textarea:focus{ border-color:var(--gold); background:rgba(0,0,0,.32); }
textarea{ min-height:130px; line-height:1.5; }
.row2{ display:flex; gap:14px; }
.row2 > div{ flex:1; }
button{ font-family:'Inter',sans-serif; font-weight:600; font-size:15px; border:none; border-radius:10px; padding:14px 20px; cursor:pointer; transition:transform .12s ease, box-shadow .12s ease, opacity .12s ease; }
button:focus-visible{ outline:2px solid var(--gold-bright); outline-offset:2px; }
button:disabled{ opacity:.55; cursor:default; }
.btn-primary{ width:100%; margin-top:24px; background:linear-gradient(135deg,var(--gold-bright),var(--gold)); color:var(--navy-deep); box-shadow:0 8px 20px rgba(201,162,75,.25); }
.btn-primary:hover:not(:disabled){ transform:translateY(-1px); }
.btn-ghost{ background:transparent; border:1px solid rgba(201,162,75,.4); color:var(--gold-bright); width:100%; margin-top:10px; }
.btn-small{ padding:10px 14px; font-size:13px; }
.hint{ font-size:12px; color:var(--muted); margin-top:6px; line-height:1.4; }
.error-msg{ font-size:13px; color:#F0A0A0; margin-top:8px; min-height:16px; }
.success-msg{ font-size:13px; color:#9BD8A6; margin-top:8px; }

/* --- email verify row --- */
.verify-row{ display:flex; gap:8px; margin-top:8px; }
.verify-row input{ flex:1; }
.code-row{ display:flex; gap:8px; margin-top:10px; align-items:center; }
.code-row input{ letter-spacing:4px; font-size:18px; text-align:center; }
.badge-verified{ display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:#9BD8A6; margin-top:8px; }

/* --- link box --- */
.link-box{ display:flex; gap:8px; margin-top:22px; align-items:center; }
.link-box input{ flex:1; font-size:13px; color:var(--gold-bright); background:rgba(0,0,0,.3); }
.copy-btn{ background:rgba(201,162,75,.15); border:1px solid rgba(201,162,75,.4); color:var(--gold-bright); padding:12px 16px; white-space:nowrap; font-size:13px; }
.copy-btn.copied{ background:var(--gold); color:var(--navy-deep); }
.seal-icon{ width:64px;height:64px;margin:0 auto 18px; display:flex;align-items:center;justify-content:center; border-radius:50%; background:radial-gradient(circle at 35% 30%, #B8394A, var(--wax)); box-shadow:0 6px 18px rgba(142,44,58,.4), inset 0 -3px 6px rgba(0,0,0,.25); font-family:'Fraunces',serif; font-size:22px; }

/* --- envelope reveal --- */
.envelope-stage{ display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:50vh; }
.envelope-wrap{ perspective:1200px; cursor:pointer; user-select:none; }
.envelope{ width:260px; height:180px; position:relative; background:linear-gradient(155deg,#EDE0C5,var(--paper) 60%); border-radius:6px; box-shadow:0 25px 50px rgba(0,0,0,.45); transition:transform .4s ease; }
.envelope-wrap:hover .envelope{ transform:translateY(-4px); }
.flap{ position:absolute; top:0;left:0; width:0;height:0; border-left:130px solid transparent; border-right:130px solid transparent; border-top:95px solid #E3D3AD; transform-origin:top; transition:transform .7s cubic-bezier(.6,-0.1,.2,1.4); z-index:3; }
.envelope.open .flap{ transform:rotateX(180deg); }
.body-flap-l{ position:absolute; bottom:0;left:0; width:0;height:0; border-bottom:70px solid rgba(0,0,0,.06); border-right:130px solid transparent; }
.body-flap-r{ position:absolute; bottom:0;right:0; width:0;height:0; border-bottom:70px solid rgba(0,0,0,.06); border-left:130px solid transparent; }
.wax{ position:absolute; top:78px;left:50%; transform:translate(-50%,0); width:48px;height:48px; border-radius:50%; background:radial-gradient(circle at 35% 30%, #B8394A, var(--wax)); box-shadow:0 4px 10px rgba(0,0,0,.35), inset 0 -3px 5px rgba(0,0,0,.25); display:flex;align-items:center;justify-content:center; font-family:'Fraunces',serif; font-size:18px; z-index:4; transition:opacity .3s ease, transform .3s ease; }
.envelope.open .wax{ opacity:0; transform:translate(-50%,0) scale(.4); }
.letter-inside{ position:absolute; top:14px;left:20px;right:20px; height:150px; background:var(--paper); border-radius:3px; box-shadow:0 4px 10px rgba(0,0,0,.15); transition:transform .6s ease .2s; z-index:2; }
.envelope.open .letter-inside{ transform:translateY(-92px); }
.tap-hint{ margin-top:26px; color:var(--muted); font-size:13px; text-align:center; }

.letter-full{ max-width:480px; width:100%; background:var(--paper); color:var(--ink); border-radius:4px; padding:40px 36px 34px; box-shadow:0 30px 60px rgba(0,0,0,.5); opacity:0; transform:translateY(16px); animation:riseIn .6s ease forwards; animation-delay:.3s; }
@keyframes riseIn{ to{ opacity:1; transform:translateY(0); } }
.letter-full .to-line{ font-family:'Fraunces',serif; font-style:italic; font-size:15px; color:#7A6E58; margin-bottom:18px; }
.letter-full .msg{ font-family:'Fraunces',serif; font-size:19px; line-height:1.75; white-space:pre-wrap; }
.letter-full .from-line{ font-family:'Caveat',cursive; font-size:32px; color:var(--wax); margin-top:26px; text-align:right; }
.letter-full .date-line{ font-size:11px; color:#A79C86; text-align:right; margin-top:4px; }
.action-row{ display:flex; gap:10px; margin-top:22px; }
.action-row button{ flex:1; }
.link-small{ display:block; text-align:center; margin-top:16px; color:var(--muted); font-size:13px; text-decoration:none; background:none; border:none; cursor:pointer; }
.link-small:hover{ color:var(--gold-bright); }

.status{ text-align:center; color:var(--muted); font-size:14px; padding:40px 0; }
.error-box{ text-align:center; padding:30px 10px; }

/* --- Monkey overlay --- */
.monkey-overlay{ position:fixed; inset:0; z-index:50; pointer-events:none; overflow:hidden; }
.monkey-svg-wrap{ position:absolute; width:140px; }
.monkey-caption{ position:absolute; top:14%; left:50%; transform:translateX(-50%); font-family:'Fraunces',serif; font-size:20px; text-align:center; color:var(--gold-bright); opacity:0; z-index:2; text-shadow:0 2px 10px rgba(0,0,0,.6); }

/* seal sequence: monkey enters from left, exits right */
.monkey-seal .monkey-svg-wrap{
  left:-160px; bottom:14%;
  animation: monkeySealMove 3.2s cubic-bezier(.5,0,.3,1) forwards;
}
@keyframes monkeySealMove{
  0%{ left:-160px; transform:scaleX(1) rotate(0deg); }
  25%{ left:calc(50% - 70px); transform:scaleX(1) rotate(0deg); }
  55%{ left:calc(50% - 70px); transform:scaleX(1) rotate(0deg) translateY(-6px); }
  70%{ left:calc(50% - 70px); transform:scaleX(1) rotate(0deg); }
  100%{ left:120%; transform:scaleX(-1) rotate(0deg); }
}
.monkey-seal .arm-l{ animation: armGrabL 3.2s ease forwards; transform-origin:top center; }
.monkey-seal .arm-r{ animation: armGrabR 3.2s ease forwards; transform-origin:top center; }
@keyframes armGrabL{
  0%,22%{ transform:rotate(0deg); }
  35%{ transform:rotate(-70deg); }
  48%{ transform:rotate(10deg); }
  60%{ transform:rotate(-70deg); }
  100%{ transform:rotate(0deg); }
}
@keyframes armGrabR{
  0%,22%{ transform:rotate(0deg); }
  40%{ transform:rotate(70deg); }
  53%{ transform:rotate(-10deg); }
  65%{ transform:rotate(70deg); }
  100%{ transform:rotate(0deg); }
}

/* reveal sequence: monkey runs in from right holding envelope, throws it, points, exits left */
.monkey-reveal .monkey-svg-wrap{
  right:-160px; bottom:20%;
  animation: monkeyRevealMove 2.8s cubic-bezier(.5,0,.3,1) forwards;
}
@keyframes monkeyRevealMove{
  0%{ right:-160px; transform:scaleX(-1); }
  35%{ right:calc(50% - 70px); transform:scaleX(-1); }
  55%{ right:calc(50% - 70px); transform:scaleX(-1) translateY(-4px); }
  100%{ right:calc(50% - 70px); transform:scaleX(-1); }
}
.monkey-reveal .arm-r{ animation: throwArm 2.8s ease forwards; transform-origin:top center; }
@keyframes throwArm{
  0%,40%{ transform:rotate(0deg); }
  55%{ transform:rotate(-100deg); }
  65%{ transform:rotate(-10deg); }
  75%,100%{ transform:rotate(-40deg); }
}
.thrown-envelope{ position:absolute; width:60px; height:42px; background:linear-gradient(155deg,#EDE0C5,var(--paper) 60%); border-radius:4px; box-shadow:0 8px 16px rgba(0,0,0,.4); opacity:0; z-index:1; }
.monkey-reveal .thrown-envelope{ animation: envelopeThrow 2.8s ease forwards; }
@keyframes envelopeThrow{
  0%,54%{ opacity:0; right:calc(50% - 40px); bottom:34%; transform:rotate(0deg) scale(.6); }
  55%{ opacity:1; }
  75%{ right:calc(50% - 30px); bottom:8%; transform:rotate(200deg) scale(1); opacity:1; }
  100%{ right:calc(50% - 30px); bottom:8%; transform:rotate(180deg) scale(1); opacity:1; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.01ms !important; transition-duration:.01ms !important; }
}
@media (max-width:480px){
  .row2{ flex-direction:column; gap:0; }
  .action-row{ flex-direction:column; }
}

/* --- Admin --- */
.admin-wrap{ max-width:900px; width:100%; }
table{ width:100%; border-collapse:collapse; margin-top:20px; font-size:13.5px; }
th,td{ text-align:left; padding:10px 12px; border-bottom:1px solid rgba(201,162,75,.15); vertical-align:top; }
th{ color:var(--gold-bright); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
tr.reply-row td:first-child{ padding-left:28px; color:var(--muted); }
.pill{ display:inline-block; padding:2px 8px; border-radius:20px; font-size:11px; background:rgba(201,162,75,.15); color:var(--gold-bright); }
