:root {
  --ink: #201d19;
  --muted: #716a61;
  --paper: #f7f2e9;
  --paper-strong: #fffdf8;
  --line: rgba(50, 43, 35, 0.14);
  --accent: #b5533c;
  --shadow: 0 24px 70px rgba(52, 40, 28, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.page-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 10%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 30rem),
    linear-gradient(135deg, #faf7f0, #eee6d9);
}

.personal-page .page-background {
  background: linear-gradient(145deg, #47423b, #1f1c18);
}

.personal-page .page-background::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(24, 21, 17, 0.48), rgba(24, 21, 17, 0.66)), var(--personal-background);
  background-position: center;
  background-size: cover;
  opacity: 0;
}

.personal-page[style*="--personal-background"] .page-background::before { opacity: 1; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  height: 86px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.personal-page .site-header { color: white; }

.centered-page { display: flex; flex-direction: column; }

.centered-page .site-header { flex: 0 0 auto; }

.welcome-shell,
.riddle-card {
  width: min(650px, calc(100% - 36px));
  margin: auto;
  padding: 58px 62px;
  text-align: center;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.welcome-shell { background: transparent; box-shadow: none; }
.welcome-shell.compact { background: var(--paper-strong); box-shadow: var(--shadow); }

.photo-stack {
  position: relative;
  width: 150px;
  height: 112px;
  margin: 0 auto 40px;
}

.photo-stack span {
  position: absolute;
  inset: 0 20px;
  background: #d7c4a8;
  border: 9px solid white;
  box-shadow: 0 12px 30px rgba(53, 43, 32, 0.2);
}
.photo-stack span:nth-child(1) { transform: rotate(-10deg); background: #9cb2a2; }
.photo-stack span:nth-child(2) { transform: rotate(8deg); background: #c89877; }
.photo-stack span:nth-child(3) { transform: rotate(-1deg); background: linear-gradient(145deg, #7f9ca1 48%, #d1ad7f 49%); }

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

h1 { font-size: clamp(2.6rem, 7vw, 4.8rem); }
h2 { font-size: clamp(1.8rem, 4vw, 2.75rem); }

.lead {
  margin: 24px auto 0;
  max-width: 630px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.7;
  white-space: pre-line;
}

.privacy-note, .aside-note {
  margin: 32px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.privacy-note span { color: var(--accent); margin-right: 7px; }

.contact-note { margin: 18px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.7; }
.contact-note a { color: var(--accent); overflow-wrap: anywhere; text-underline-offset: 3px; }

.riddle-card { width: min(540px, calc(100% - 36px)); }
.riddle-card h1 { font-size: clamp(2.7rem, 9vw, 4.5rem); }
.riddle-rule { width: 42px; height: 2px; margin: 25px auto; background: var(--accent); }
.riddle-prompt { margin: 0 auto 28px; max-width: 380px; color: var(--muted); font-size: 1.08rem; line-height: 1.65; white-space: pre-line; }
.riddle-form { display: grid; gap: 10px; text-align: left; }
.riddle-form label { font-size: 0.8rem; font-weight: 750; }
.riddle-form input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: white;
}
.riddle-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.field-error { color: #9d2f27; font-size: 0.85rem; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 50px;
  padding: 0 22px;
  color: white;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  cursor: pointer;
  font-weight: 750;
  transition: transform 150ms ease, filter 150ms ease;
}
.primary-button:hover { transform: translateY(-1px); filter: brightness(0.94); }
.primary-button:disabled {
  color: color-mix(in srgb, var(--accent) 72%, #302923);
  background: color-mix(in srgb, var(--accent) 34%, white);
  cursor: not-allowed;
  transform: none;
}
.riddle-form .primary-button { margin-top: 8px; }

.quiet-button {
  padding: 9px 12px;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  opacity: 0.8;
  font-size: 0.8rem;
}

.gallery-page .page-background::before { position: fixed; }
.gallery-page .page-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0, transparent 410px, var(--paper) 760px);
}

.gallery-shell { width: min(1180px, calc(100% - 40px)); margin: 34px auto 90px; }

.hero-card {
  min-height: 330px;
  padding: 58px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  color: white;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(31, 27, 23, 0.54), rgba(31, 27, 23, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.hero-card .eyebrow { color: color-mix(in srgb, var(--accent) 60%, white); }
.hero-card .lead { margin-left: 0; color: rgba(255,255,255,0.82); }

.collection-stats { display: flex; gap: 10px; }
.collection-stats div {
  width: 128px;
  min-height: 112px;
  padding: 17px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
}
.collection-stats strong { font-family: Georgia, serif; font-size: 2.35rem; font-weight: 500; }
.collection-stats span { font-size: 0.7rem; opacity: 0.75; }

.message-stack { margin: 20px 0; display: grid; gap: 10px; }
.message { padding: 14px 18px; border-radius: 10px; background: #fff; border-left: 4px solid var(--accent); box-shadow: 0 8px 24px rgba(40,35,30,0.08); }
.message.error { border-left-color: #a83b32; }

.upload-card {
  margin-top: 24px;
  padding: 40px 46px;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(390px, 1.2fr);
  gap: 50px;
  align-items: center;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
}
.upload-card p:not(.eyebrow) { color: var(--muted); line-height: 1.6; font-size: 0.9rem; }
.upload-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.drop-zone {
  min-height: 118px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, #aaa);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 4%, white);
  cursor: pointer;
  text-align: center;
}
.drop-zone:hover, .drop-zone.is-dragging { background: color-mix(in srgb, var(--accent) 9%, white); }
.drop-zone strong { color: var(--ink); }
.drop-zone span:last-child { margin-top: 3px; font-size: 0.78rem; }
.upload-icon { color: var(--accent); font-size: 1.55rem; font-weight: 300; }
.upload-progress { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 5px; background: #e4ddd3; }
.upload-progress span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 120ms linear; }

.closed-note { margin: 24px 0; padding: 22px; background: #fff8df; border: 1px solid #ded1a7; border-radius: 16px; }

.milestone {
  display: inline-block;
  margin: 22px 0 0;
  padding: 9px 14px;
  color: #fff5df;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  font-size: 0.85rem;
  line-height: 1.5;
}
.riddle-hint { margin: 8px 0; color: var(--accent); font-size: 0.9rem; line-height: 1.6; white-space: pre-line; }
.thank-you-flourish { position: relative; overflow: hidden; margin: 20px 0; padding: 24px; border: 1px solid #daceaf; border-radius: 16px; background: #fff7df; text-align: center; }
.thank-you-flourish p { position: relative; margin: 0; color: #69502d; line-height: 1.5; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; left: calc(8% + var(--piece) * 12%); top: -14px; width: 8px; height: 12px; background: var(--accent); animation: confetti-fall 1.8s ease-out both; animation-delay: calc(var(--piece) * 70ms); }
.confetti i:nth-child(even) { background: #75968b; }
.confetti i:nth-child(3n) { background: #d2ab53; }
@keyframes confetti-fall { from { transform: translateY(0) rotate(0); opacity: 1; } to { transform: translateY(120px) rotate(210deg); opacity: 0; } }

.photos-section { margin-top: 70px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 26px; }
.section-heading > p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.6; text-align: right; white-space: pre-line; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.photo-card { align-self: start; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 7px 26px rgba(45,38,31,0.06); }
.photo-link { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #e7e1d8; }
.photo-link img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 250ms ease; }
.photo-link:hover img { transform: scale(1.025); }
.photo-meta { min-width: 0; padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.photo-meta > span { overflow: hidden; color: var(--muted); font-size: 0.74rem; text-overflow: ellipsis; white-space: nowrap; }
.photo-actions { display: flex; align-items: center; gap: 4px; }
.photo-actions a, .photo-actions button { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); border: 0; border-radius: 7px; background: transparent; cursor: pointer; text-decoration: none; }
.photo-actions a:hover, .photo-actions button:hover { color: var(--ink); background: #f1ece5; }
.photo-actions form { margin: 0; }

.resolution-warning { padding: 0 12px 10px; color: #69502d; font-size: 0.78rem; }
.resolution-warning summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: 6px; list-style: none; }
.resolution-warning summary::-webkit-details-marker { display: none; }
.resolution-warning summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.resolution-warning p { margin: 4px 0 0; line-height: 1.6; }

.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 18px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 20px; text-align: center; }
.empty-state p { max-width: 470px; margin: 0 24px; line-height: 1.6; white-space: pre-line; }
.empty-frame { width: 58px; height: 58px; display: grid; place-items: center; color: var(--accent); border: 2px solid currentColor; transform: rotate(-4deg); font-size: 1.5rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .hero-card { grid-template-columns: 1fr; align-items: end; }
  .collection-stats { justify-content: flex-start; }
  .upload-card { grid-template-columns: 1fr; gap: 28px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .site-header { width: calc(100% - 28px); height: 70px; }
  .wordmark { font-size: 1rem; }
  .welcome-shell, .riddle-card { padding: 38px 26px; border-radius: 20px; }
  .gallery-shell { width: calc(100% - 24px); margin-top: 14px; }
  .hero-card { min-height: 370px; padding: 34px 25px; border-radius: 22px; }
  .collection-stats { width: 100%; }
  .collection-stats div { width: auto; flex: 1; min-height: 96px; }
  .upload-card { padding: 28px 20px; border-radius: 18px; }
  .upload-form { grid-template-columns: 1fr; }
  .upload-form .primary-button { min-height: 54px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 14px; text-align: left; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photos-section { margin-top: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .confetti { display: none; }
  .confetti i { animation: none; }
}
