:root {
  --paper-0: #f3e9d2;
  --paper-1: #ece0c4;
  --card: #fbf4e4;
  --ink: #3a3024;
  --ink-dim: #8a7a5c;
  --stamp: #d98a4e;
  --stamp-deep: #b9823f;
  --postmark: #7c5b32;
  --future-bubble: #fbf4e4;
  --you-bubble: #efe6cf;
}

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

html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 650px at 50% -10%, #f7eed9 0%, transparent 60%),
    linear-gradient(180deg, var(--paper-1) 0%, var(--paper-0) 100%);
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  overflow-x: hidden;
}

/* Faint paper grain built from layered dot gradients -- no images. */
.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 15% 25%, rgba(124, 91, 50, 0.14) 50%, transparent 51%),
    radial-gradient(1px 1px at 65% 15%, rgba(124, 91, 50, 0.10) 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 65%, rgba(124, 91, 50, 0.12) 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 55%, rgba(124, 91, 50, 0.09) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 85%, rgba(124, 91, 50, 0.11) 50%, transparent 51%);
  opacity: 0.8;
}

.stage {
  position: relative;
  width: min(680px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(16px, 3vw, 28px);
}

.stage__head {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.postcard-emblem {
  width: clamp(200px, 46vw, 300px);
  aspect-ratio: 220 / 150;
  filter: drop-shadow(0 10px 22px rgba(124, 91, 50, 0.28));
  transform: rotate(-2deg);
}

.postcard__svg { width: 100%; height: 100%; display: block; }

.postcard__stamp { animation: stamp-settle 6s ease-in-out infinite; transform-origin: 185px 38px; }
.postcard__postmark { animation: postmark-fade 6s ease-in-out infinite; transform-origin: 150px 30px; }

@keyframes stamp-settle {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(1.5deg); }
}
@keyframes postmark-fade {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

.title {
  font-family: "Gelasio", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 3.1rem);
  letter-spacing: 0.5px;
  color: var(--postmark);
}

.tagline {
  color: var(--ink-dim);
  font-style: italic;
  font-family: "Gelasio", Georgia, serif;
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  max-width: 36ch;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 120px;
  padding: 4px;
}

.bubble {
  padding: 16px 20px;
  border-radius: 10px;
  line-height: 1.6;
  max-width: 92%;
  animation: rise 0.4s ease-out both;
  font-size: clamp(0.98rem, 2.6vw, 1.08rem);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* The future self writes on postcard stock: cream card, dashed border, a touch
   of handwriting feel. */
.bubble--future {
  align-self: flex-start;
  background: var(--future-bubble);
  border: 1.5px dashed var(--stamp-deep);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(124, 91, 50, 0.14);
  font-family: "Caveat", "Gelasio", Georgia, cursive;
  font-size: clamp(1.2rem, 3.2vw, 1.5rem);
  color: var(--ink);
}

.bubble--you {
  align-self: flex-end;
  background: var(--you-bubble);
  border: 1px solid rgba(124, 91, 50, 0.3);
  border-top-right-radius: 2px;
  color: var(--postmark);
  font-weight: 500;
}

/* The ongoing note gets a faint stamp-colored edge. */
.bubble--note {
  border-left: 4px solid var(--stamp);
}

/* The sign-off is centered and framed like a kept keepsake. */
.bubble--signoff {
  align-self: center;
  text-align: center;
  max-width: 100%;
  background: linear-gradient(135deg, rgba(217, 138, 78, 0.12), rgba(251, 244, 228, 0.9));
  border: 1.5px dashed var(--stamp-deep);
  box-shadow: 0 6px 24px rgba(124, 91, 50, 0.2);
}

.bubble--thinking {
  color: var(--ink-dim);
  font-style: italic;
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(0.98rem, 2.6vw, 1.08rem);
}
.bubble--thinking::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.opener { display: flex; gap: 10px; flex-wrap: wrap; }

.opener__input {
  flex: 1 1 240px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(124, 91, 50, 0.4);
  background: rgba(255, 253, 246, 0.85);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}
.opener__input::placeholder { color: var(--ink-dim); font-style: italic; }
.opener__input:focus {
  outline: none;
  border-color: var(--stamp);
  box-shadow: 0 0 0 3px rgba(217, 138, 78, 0.22);
}

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

.again { display: flex; justify-content: center; }

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-width: 96px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(90deg, var(--stamp-deep), var(--stamp));
  box-shadow: 0 6px 20px rgba(185, 130, 63, 0.4);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .postcard__stamp, .postcard__postmark { animation: none; }
  .bubble { animation: none; }
}
