:root {
  --bg: #020206;
  --ink: #f4ece1;
  --muted: rgba(244, 236, 225, 0.62);
  --gold: #e8c38a;
  --gold-2: #ffdca8;
  --glass: rgba(14, 14, 28, 0.62);
  --line: rgba(232, 195, 138, 0.28);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font-family: var(--sans); -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; cursor: grab; }

.show { opacity: 1 !important; pointer-events: auto !important; visibility: visible !important; }

.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 24px 16px; text-align: center;
  background: radial-gradient(ellipse at 50% 60%, #0d0b1c 0%, var(--bg) 70%);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity 1.2s ease, visibility 1.2s;
}
.screen h1 { font-family: var(--serif); font-weight: 400; font-style: italic; font-size: clamp(44px, 11vw, 88px); line-height: 1; color: var(--gold-2); }
.screen .lead { font-family: var(--serif); font-size: clamp(22px, 5.4vw, 34px); color: var(--ink); margin-top: -8px; }
.screen .note { font-size: 13px; color: var(--muted); max-width: 30ch; line-height: 1.5; }
#lock-time { font-family: var(--serif); font-size: clamp(54px, 16vw, 120px); letter-spacing: 0.04em; color: var(--ink); font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(232, 195, 138, 0.35); }
#lock-sub { color: var(--muted); font-size: 14px; letter-spacing: 0.08em; }

.btn {
  font: 500 16px/1 var(--sans); letter-spacing: 0.06em; color: #1b1308;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border: 0; border-radius: 999px; padding: 16px 34px; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 220, 168, 0.4), 0 10px 40px rgba(232, 170, 90, 0.35);
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 220, 168, 0.6), 0 14px 50px rgba(232, 170, 90, 0.5); }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); color: var(--ink); box-shadow: 0 0 0 1px var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

#caption {
  position: fixed; left: 50%; top: 16%; transform: translate(-50%, 10px); z-index: 5;
  width: min(92vw, 680px); text-align: center; white-space: pre-line;
  font-family: var(--serif); font-size: clamp(24px, 6vw, 38px); line-height: 1.25; color: var(--ink);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9);
  opacity: 0; pointer-events: none; filter: blur(6px);
  transition: opacity 1s ease, transform 1.2s ease, filter 1s ease;
}
#caption.show { transform: translate(-50%, 0); filter: blur(0); }
#caption.title { font-style: italic; font-size: clamp(34px, 8.5vw, 60px); color: var(--gold-2); text-shadow: 0 0 40px rgba(232, 170, 90, 0.45), 0 2px 20px #000; }
#caption.high { top: 5%; font-size: clamp(28px, 7vw, 48px); }
#caption.wide { top: auto; bottom: 14%; font-size: clamp(20px, 5vw, 30px); }
#caption.soft { top: auto; bottom: 16%; font-family: var(--sans); font-size: 15px; letter-spacing: 0.14em; color: var(--gold); animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

#hint {
  position: fixed; left: 0; right: 0; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 5;
  text-align: center; font-size: 13px; letter-spacing: 0.1em; color: var(--muted);
  opacity: 0; pointer-events: none; transition: opacity 1s;
}
#hold {
  position: fixed; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  opacity: 0; pointer-events: none; transition: opacity 1s; touch-action: none; -webkit-touch-callout: none;
  font-size: 14px; padding: 14px 26px;
}

#dots {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5;
  display: flex; gap: 7px; opacity: 0; pointer-events: none; transition: opacity 1.2s;
}
#dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(244, 236, 225, 0.18); transition: background 0.6s, box-shadow 0.6s; }
#dots i.on { background: var(--gold-2); box-shadow: 0 0 8px var(--gold); }

#card {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(2, 2, 6, 0.35), rgba(2, 2, 6, 0.7));
  opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.6s ease, visibility 0.6s;
}
.card-in {
  position: relative; width: min(100%, 420px); padding: 28px 26px 30px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 22px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(18px) scale(0.97); transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#card.show .card-in { transform: none; }
.card-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-bottom: 18px; }
#card-star { color: var(--muted); text-align: right; }
#card-photo { width: 100%; max-height: 46vh; object-fit: cover; border-radius: 12px; margin-bottom: 18px; }
#card-date { font-size: 12px; letter-spacing: 0.08em; color: var(--gold-2); opacity: 0.8; margin-bottom: 10px; }
#card-date:empty { display: none; }
#card-text { font-family: var(--serif); font-size: clamp(22px, 5.6vw, 28px); line-height: 1.3; }
#card-close {
  position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #0d0c18; color: var(--gold-2);
  font-size: 18px; cursor: pointer;
}

#letter-btn { position: fixed; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; opacity: 0; pointer-events: none; transition: opacity 1.2s; }

#letter {
  position: fixed; inset: 0; z-index: 9; overflow-y: auto; touch-action: pan-y;
  display: flex; flex-direction: column; align-items: center; padding: max(10vh, 40px) 16px 60px;
  background: rgba(2, 2, 6, 0.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 1.4s, visibility 1.4s;
}
#letter-body { width: min(100%, 560px); font-family: var(--serif); font-size: clamp(21px, 5vw, 26px); line-height: 1.5; }
#letter-body p { margin-bottom: 1em; opacity: 0; transform: translateY(12px); filter: blur(4px); transition: opacity 1.6s, transform 1.6s, filter 1.6s; }
#letter-body p.in { opacity: 1; transform: none; filter: none; }
#letter-body .greet { font-style: italic; font-size: 1.5em; color: var(--gold-2); }
#letter-body .sign { font-style: italic; font-size: 1.25em; color: var(--gold-2); margin-top: 1.4em; }
#letter-body .gift { font-family: var(--sans); font-size: 15px; letter-spacing: 0.04em; color: var(--gold); padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(232, 195, 138, 0.06); }
#again { opacity: 0; pointer-events: none; transition: opacity 1s; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  #caption { filter: none; }
}
