@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Caveat:wght@600;700&display=swap');

:root {
  --accent: #ff5fa2;
  --accent2: #7b6cff;
  --accent3: #ffb86b;
  --ink: #1a1a2e;
  --muted: #9b9bc4;
  --glass: rgba(255,255,255,0.07);
  --glass-border: rgba(255,255,255,0.14);
}

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

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: #0b0c1f;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,95,162,0.25), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(123,108,255,0.25), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(255,184,107,0.15), transparent 50%),
    linear-gradient(160deg, #0b0c1f 0%, #14152e 50%, #0b0c1f 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: #fff;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.page { width: 100%; max-width: 760px; padding: 48px 22px 70px; }

/* ---------- Brand / Header ---------- */
.brand { text-align: center; margin-bottom: 36px; }
.brand .logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-size: 1.8rem; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(255,95,162,0.35);
}
.brand h1 {
  font-size: 2.3rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #cfd2ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
}
.brand p { color: var(--muted); font-size: 1rem; font-weight: 400; }

/* ---------- Template grid ---------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
}

.template-card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 20px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, border-color .25s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  overflow: hidden;
}
.template-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent 60%);
  opacity: 0; transition: opacity .25s ease;
}
.template-card:not(.disabled):hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 20px 40px rgba(123,108,255,0.25);
}
.template-card:not(.disabled):hover::before { opacity: 1; }
.template-card.disabled { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.4); }

.template-preview {
  width: 100%;
  height: 120px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.tpl1-preview {
  background: linear-gradient(135deg, var(--accent), var(--accent2) 60%, var(--accent3));
}
.tpl1-preview::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.35), transparent 50%);
}
.tpl-soon { background: rgba(255,255,255,0.06); border: 1px dashed rgba(255,255,255,0.2); }
.emoji { font-size: 2.2rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.25)); }
.template-preview strong { font-weight: 700; font-size: 0.95rem; text-shadow: 0 2px 6px rgba(0,0,0,0.2); }

.use-btn {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}
.disabled .use-btn { background: rgba(255,255,255,0.12); color: #aaa; box-shadow: none; }

.foot { text-align: center; margin-top: 48px; color: var(--muted); font-size: 0.82rem; }
.foot p { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Form page ---------- */
.back-link {
  color: var(--muted); text-decoration: none; font-size: 0.88rem;
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 18px; transition: color .2s ease;
}
.back-link:hover { color: #fff; }

.form-wrap {
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  padding: 30px 26px;
  margin-top: 6px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
}

.form-wrap label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 600; margin: 18px 0 8px; color: #d8d8f5;
  letter-spacing: 0.01em;
}
.form-wrap label:first-of-type { margin-top: 0; }

.form-wrap input[type=text], .form-wrap textarea {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid transparent;
  background: rgba(255,255,255,0.95); color: var(--ink); font-size: 0.97rem; font-family: inherit;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.form-wrap input[type=text]:focus, .form-wrap textarea:focus {
  outline: none; border-color: var(--accent2);
  box-shadow: 0 0 0 4px rgba(123,108,255,0.25);
}
.form-wrap textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

.char-count { display: block; text-align: right; font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

.img-drop {
  border: 2px dashed rgba(255,255,255,0.25);
  border-radius: 16px;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  color: #cfd2ff;
  font-size: 0.88rem;
  transition: border-color .2s ease, background .2s ease;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.img-drop:hover { border-color: var(--accent); background: rgba(255,95,162,0.06); }
.img-drop .drop-icon { font-size: 1.6rem; }
.img-preview {
  max-width: 140px; max-height: 140px; border-radius: 50%; object-fit: cover;
  margin-top: 14px; display: none; border: 3px solid rgba(255,255,255,0.6);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.submit-btn {
  margin-top: 26px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(255,95,162,0.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.submit-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(255,95,162,0.45); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.status-msg { margin-top: 14px; font-size: 0.85rem; text-align: center; min-height: 20px; font-weight: 500; }
.status-msg.error { color: #ff8a8a; }
.status-msg.ok { color: #7af0a0; }

.result-box {
  margin-top: 18px;
  background: linear-gradient(135deg, rgba(255,95,162,0.15), rgba(123,108,255,0.15));
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 18px;
  display: none;
  word-break: break-all;
  text-align: center;
}
.result-box .result-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.result-box a { color: #fff; font-weight: 600; font-size: 0.95rem; text-decoration: none; }
.result-box a:hover { text-decoration: underline; }
.copy-btn {
  margin-top: 12px; padding: 9px 18px; border-radius: 999px; border: none;
  background: #fff; color: var(--ink); font-weight: 600; font-size: 0.82rem; cursor: pointer;
  transition: transform .15s ease;
}
.copy-btn:hover { transform: translateY(-1px); }
.expiry-note { margin-top: 10px; font-size: 0.75rem; opacity: 0.75; }

/* ---------- Card View (server-rendered) ---------- */
.card-view-wrap {
  display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 24px;
  position: relative; overflow: hidden;
}
.confetti-bg {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image:
    radial-gradient(circle, rgba(255,95,162,0.5) 2px, transparent 2.5px),
    radial-gradient(circle, rgba(255,184,107,0.5) 2px, transparent 2.5px),
    radial-gradient(circle, rgba(123,108,255,0.5) 2px, transparent 2.5px);
  background-size: 60px 60px, 90px 90px, 75px 75px;
  background-position: 0 0, 30px 40px, 50px 10px;
}

.wish-card {
  position: relative;
  background: linear-gradient(155deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 28px;
  padding: 44px 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05) inset;
  animation: cardIn .6s cubic-bezier(.2,.8,.2,1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wish-card .ribbon {
  display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent3); margin-bottom: 14px;
}

.wish-card .photo-wrap {
  width: 130px; height: 130px; margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2), var(--accent3));
  padding: 4px;
  box-shadow: 0 12px 30px rgba(255,95,162,0.4);
}
.wish-card img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  border: 3px solid rgba(11,12,31,0.9);
  display: block;
}

.wish-card h2 {
  font-size: 1.9rem; font-weight: 800; margin-bottom: 18px; line-height: 1.25;
  background: linear-gradient(135deg, #fff, #ffd9ec);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.wish-card .wish-text {
  font-family: 'Caveat', cursive;
  font-size: 1.55rem; line-height: 1.5; margin-bottom: 24px; white-space: pre-wrap;
  color: #fff; font-weight: 600;
}

.wish-card .from {
  font-size: 0.92rem; opacity: 0.8; font-style: italic;
}
.wish-card .from::before { content: '— '; }

.wish-card .cta-row { margin-top: 28px; }
.wish-card .make-own {
  display: inline-block; font-size: 0.78rem; color: var(--muted); text-decoration: none;
  border: 1px solid rgba(255,255,255,0.15); padding: 8px 16px; border-radius: 999px;
  transition: border-color .2s ease, color .2s ease;
}
.wish-card .make-own:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

.expired-box {
  text-align: center; color: #fff;
  background: var(--glass); backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border); border-radius: 24px; padding: 50px 32px;
  max-width: 380px;
}
.expired-box .big-emoji { font-size: 2.6rem; margin-bottom: 14px; }
.expired-box h2 { font-size: 1.4rem; margin-bottom: 10px; font-weight: 700; }
.expired-box p { color: var(--muted); margin-bottom: 18px; font-size: 0.92rem; }
.expired-box .back-link { margin: 0; justify-content: center; }

@media (max-width: 420px) {
  .wish-card { padding: 34px 22px; }
  .wish-card h2 { font-size: 1.5rem; }
  .wish-card .wish-text { font-size: 1.3rem; }
}