:root {
  --pink: #ff8fb1;
  --pink-soft: #ffe3ec;
  --lav: #c9b8ff;
  --mint: #bff0dc;
  --ink: #4a3b52;
  --font: 'Mali', 'Noto Sans TC', 'Noto Color Emoji', system-ui, sans-serif;
  --script: 'Pacifico', 'Mali', 'Noto Color Emoji', cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); }
button, input, textarea { font: inherit; color: inherit; }

/* ───────────── Cards (shared) ───────────── */
.card {
  position: relative;
  border-radius: 22px;
  padding: 1.3em 1.2em 1em;
  box-shadow: 0 6px 18px rgba(80, 40, 90, 0.15);
  overflow: visible;
  isolation: isolate;
}
.decor { font-family: 'Noto Color Emoji', sans-serif; position: absolute; font-size: 2.1em; line-height: 1; z-index: 2; pointer-events: none; }
.d-tl { top: -0.45em; left: -0.35em; transform: rotate(-12deg); }
.d-tr { top: -0.45em; right: -0.35em; transform: rotate(12deg); }
.d-bl { bottom: -0.4em; left: -0.4em; transform: rotate(-6deg); }
.d-br { bottom: -0.4em; right: -0.4em; transform: rotate(8deg); }
.card-body { position: relative; z-index: 1; }
.photo { margin: 0 0 0.7em; }
.photo img { display: block; width: 100%; max-height: 22em; object-fit: cover; border-radius: 14px; border: 3px solid rgba(255, 255, 255, 0.9); }
.quote {
  display: inline-block;
  font-weight: 700;
  padding: 0.35em 0.85em;
  border-radius: 999px;
  transform: rotate(-2deg);
  margin: 0.1em 0 0.5em;
  line-height: 1.35;
}
.msg { margin: 0.2em 0 0.6em; font-size: 1.08em; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.from { text-align: right; font-weight: 600; opacity: 0.85; }
.burst {
  position: absolute; z-index: 3; top: -0.9em; right: 2.4em;
  font-weight: 800; font-size: 0.95em; color: #fff;
  padding: 0.9em 0.8em; background: #ff4d6d;
  clip-path: polygon(50% 0, 61% 25%, 90% 12%, 78% 40%, 100% 52%, 76% 63%, 86% 92%, 58% 78%, 45% 100%, 37% 76%, 8% 88%, 22% 60%, 0 45%, 25% 36%, 14% 8%, 40% 22%);
  transform: rotate(10deg);
}
.theme-dino .burst { background: #59b36a; }

.theme-dino { background: linear-gradient(160deg, #e9fbe5, #fff6d6); border: 3px dashed #7cc47f; color: #2f5a33; }
.theme-dino .quote { background: #7cc47f; color: #fff; }

.theme-meadow { background: linear-gradient(#e6f4ff 0%, #fffdf3 55%, #dff5cf 100%); border: 3px solid #f7c6d9; color: #5b4a3a; }
.theme-meadow .quote { background: #ffd6e7; color: #8a3b5c; }

.theme-pets {
  background-color: #fff7ec;
  background-image: radial-gradient(#f6dcc0 14%, transparent 15%);
  background-size: 26px 26px;
  border: 3px solid #e8b98a; color: #6b4426;
}
.theme-pets .quote { background: #e8a46f; color: #fff; }

.theme-cartoon {
  background-color: #fff36b;
  background-image: radial-gradient(rgba(255, 120, 0, 0.22) 22%, transparent 24%);
  background-size: 11px 11px;
  border: 4px solid #1b1b1b; box-shadow: 7px 7px 0 #1b1b1b; color: #1b1b1b;
}
.theme-cartoon .quote { background: #fff; border: 3px solid #1b1b1b; border-radius: 16px; transform: rotate(-3deg); }

.theme-chinese {
  background: radial-gradient(circle at 50% 30%, #dc2a2f, #9e0f14);
  border: 5px double #f5c451; color: #fff4d6;
  overflow: hidden;
}
.theme-chinese .decor { font-size: 1.8em; }
.theme-chinese .d-tl { top: 0.1em; left: 0.15em; }
.theme-chinese .d-tr { top: 0.1em; right: 0.15em; }
.theme-chinese .d-bl { bottom: 0.1em; left: 0.15em; }
.theme-chinese .d-br { bottom: 0.1em; right: 0.15em; }
.theme-chinese .card-body { padding: 0.9em 0.6em 0.6em; }
.theme-chinese .quote { background: #f5c451; color: #7d0a0e; }
.xi {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 0;
  font-size: 8em; color: rgba(245, 196, 81, 0.16); font-family: 'Noto Sans TC', serif; font-weight: 700; pointer-events: none;
}

/* ───────────── Guest page ───────────── */
body.guest {
  min-height: 100vh;
  background: linear-gradient(180deg, #fff0f5 0%, #f3edff 50%, #ebfbf3 100%);
}
.g-wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 60px; }
.g-head { text-align: center; position: relative; padding-top: 34px; }
.g-names { font-family: var(--script); font-size: 2.3rem; color: #e2668f; margin: 0.2em 0 0; line-height: 1.2; }
.g-names .amp { color: #b49cff; font-size: 0.8em; }
.g-date { margin: 0.5em 0 0.3em; letter-spacing: 0.15em; color: #8e7aa6; }
.g-intro { margin: 0.4em 0 1.2em; }
.lang-toggle {
  position: absolute; top: 0; right: 0;
  border: 2px solid var(--lav); background: #fff; border-radius: 999px; padding: 0.2em 0.8em; cursor: pointer;
}
.step { background: rgba(255, 255, 255, 0.85); border-radius: 20px; padding: 14px 14px 16px; margin: 0 0 14px; box-shadow: 0 3px 12px rgba(120, 80, 140, 0.08); }
.step h2 { font-size: 1.05rem; margin: 0 0 10px; }
.step h2 small { font-weight: 400; opacity: 0.7; }
.field { width: 100%; border: 2px solid #eadff5; border-radius: 14px; padding: 0.65em 0.8em; background: #fff; }
.field:focus { outline: none; border-color: var(--pink); }
textarea.field { min-height: 6.5em; resize: vertical; }
.counter { text-align: right; font-size: 0.85em; opacity: 0.6; margin-top: 4px; }

.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.theme-btn {
  border: 3px solid transparent; border-radius: 16px; padding: 8px 2px 6px; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.72rem; line-height: 1.2;
}
.theme-btn .ic { font-size: 1.9rem; }
.theme-btn[aria-pressed='true'] { border-color: var(--pink); background: var(--pink-soft); transform: translateY(-2px); }

.quote-list { display: flex; flex-direction: column; gap: 7px; }
.quote-btn {
  text-align: left; border: 2px solid #eadff5; background: #fff; border-radius: 14px; padding: 0.55em 0.8em; cursor: pointer;
}
.quote-btn[aria-pressed='true'] { border-color: var(--pink); background: var(--pink-soft); font-weight: 600; }
.quote-btn.none { opacity: 0.75; font-style: italic; }

.photo-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-soft {
  border: 2px dashed var(--lav); background: #fff; border-radius: 14px; padding: 0.6em 1em; cursor: pointer;
}
.photo-thumb { position: relative; }
.photo-thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; display: block; }
.photo-thumb button {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: #e2668f; color: #fff; cursor: pointer; line-height: 1;
}

.preview-wrap { padding: 14px 10px 18px; }
.preview-wrap .card { font-size: 0.95rem; }

.send {
  width: 100%; border: none; border-radius: 999px; padding: 0.85em; font-size: 1.15rem; font-weight: 700; cursor: pointer;
  color: #fff; background: linear-gradient(90deg, #ff8fb1, #b49cff); box-shadow: 0 6px 16px rgba(226, 102, 143, 0.35);
}
.send:disabled { opacity: 0.55; cursor: wait; }
.err { color: #c62f5b; text-align: center; min-height: 1.4em; margin: 8px 0 0; }

.done { text-align: center; padding: 40px 10px; }
.done .big { font-size: 4rem; }
.done h2 { margin: 0.3em 0; }
.done .card { text-align: left; margin: 26px 8px; font-size: 0.95rem; }

/* ───────────── Display screen ───────────── */
body.display {
  height: 100vh; overflow: hidden;
  background: linear-gradient(135deg, #ffe3ec 0%, #efe6ff 45%, #e2f8ee 100%);
  font-size: clamp(12px, 1.05vw, 22px);
}
.d-head { position: relative; z-index: 5; text-align: center; padding: 1.1em 0 0.4em; }
.d-names { font-family: var(--script); font-size: 4.2em; color: #e2668f; line-height: 1.1; margin: 0 0 0.25em; text-shadow: 0 3px 0 #fff; }
.d-names .amp { color: #b49cff; font-size: 0.75em; }
.d-sub { letter-spacing: 0.2em; color: #8e7aa6; font-size: 1.3em; margin-top: 0.5em; }
.d-count { position: absolute; left: 1.5em; top: 1.4em; font-size: 1.3em; background: #fff; border-radius: 999px; padding: 0.3em 0.9em; box-shadow: 0 3px 10px rgba(120, 80, 140, 0.12); }

.wall { position: relative; z-index: 2; column-count: 4; column-gap: 2.2em; padding: 1.6em 15em 2em 2.4em; height: calc(100vh - 9em); overflow: hidden; }
.wall .card { break-inside: avoid; margin: 0 0 2.2em; font-size: 0.95em; animation: pop-in 0.6s ease-out both; }
.wall .card .photo img { max-height: 13em; }
.empty { position: absolute; inset: 40% 0 auto; text-align: center; font-size: 2em; color: #8e7aa6; z-index: 2; }

.qr-box {
  position: fixed; z-index: 6; right: 1.6em; bottom: 1.6em; width: 12em; background: #fff; border-radius: 1.2em;
  padding: 0.9em; text-align: center; box-shadow: 0 8px 24px rgba(120, 80, 140, 0.2);
}
.qr-box .qr svg, .qr-box .qr img { width: 100%; height: auto; display: block; }
.qr-box p { margin: 0.5em 0 0; font-size: 0.95em; line-height: 1.3; }

.spot { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(60, 30, 70, 0.35); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.5s; }
.spot.on { opacity: 1; }
.spot .card { width: min(34em, 56vw); font-size: 1.6em; }
.spot .card:has(.photo) { width: min(40em, 60vw); }
.spot .card .photo img { max-height: 48vh; }
.spot .new-tag { position: absolute; top: 6vh; left: 0; right: 0; text-align: center; font-size: 2.2em; color: #fff; font-weight: 700; text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3); }

.spot.on .theme-dino { animation: stomp 1s ease-out both; }
.spot.on .theme-meadow { animation: float-in 1.1s ease-out both; }
.spot.on .theme-pets { animation: pop-in 0.7s ease-out both; }
.spot.on .theme-pets .decor { animation: wag 0.5s ease-in-out 1s 6 alternate; }
.spot.on .theme-cartoon { animation: pop-big 0.5s ease-out both, shake 0.5s 0.5s 2; }
.spot.on .theme-chinese { animation: pop-in 0.8s ease-out both; }
.spot.on .theme-chinese::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 226, 140, 0.55) 50%, transparent 70%);
  animation: shimmer 1.6s 0.6s 2 both;
}

.floaty { position: fixed; z-index: 1; bottom: -2em; pointer-events: none; animation: rise linear forwards; opacity: 0.7; }
.petal { position: fixed; z-index: 25; top: -2em; pointer-events: none; animation: fall linear forwards; }

@keyframes pop-in { from { opacity: 0; transform: scale(0.7) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes pop-big { from { opacity: 0; transform: scale(0.3) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes float-in { from { opacity: 0; transform: translateY(-40px) rotate(-3deg); } to { opacity: 1; transform: none; } }
@keyframes stomp {
  0% { opacity: 0; transform: translateY(-120px); }
  45% { opacity: 1; transform: translateY(0) scale(1.04, 0.94); }
  60% { transform: translateY(-18px); }
  75% { transform: translateY(0) scale(1.02, 0.97); }
  100% { transform: none; }
}
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: rotate(-2deg) translateX(-8px); } 75% { transform: rotate(2deg) translateX(8px); } }
@keyframes wag { from { rotate: -14deg; } to { rotate: 14deg; } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes rise { to { transform: translateY(-115vh) rotate(25deg); opacity: 0; } }
@keyframes fall { to { transform: translateY(115vh) rotate(320deg); } }

/* ───────────── Admin ───────────── */
body.admin { background: #f7f3fb; }
.a-wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.a-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.a-bar h1 { margin: 0 auto 0 0; font-size: 1.4rem; }
.a-btn { border: 2px solid #d9c9ef; background: #fff; border-radius: 12px; padding: 0.45em 0.9em; cursor: pointer; }
.a-btn.danger { border-color: #e2668f; color: #c62f5b; }
.a-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 26px; }
.a-item { display: flex; flex-direction: column; gap: 8px; }
.a-item.hidden .card { opacity: 0.35; filter: grayscale(1); }
.a-meta { font-size: 0.8rem; opacity: 0.7; display: flex; justify-content: space-between; align-items: center; }

/* ───────────── Printable QR card ───────────── */
body.print { background: #fff; }
.p-card { width: 105mm; min-height: 148mm; margin: 10mm auto; border: 2px dashed #f2b6c9; border-radius: 8mm; padding: 10mm 8mm; text-align: center; }
.p-card .g-names { font-size: 2.1rem; }
.p-card .qr { width: 60mm; margin: 6mm auto; }
.p-card .qr svg, .p-card .qr img { width: 100%; height: auto; display: block; }
.p-card p { margin: 0.2em 0; }
@media print { .noprint { display: none; } .p-card { margin: 0 auto; } }
