@font-face {
  font-family: 'Hatter';
  src: url('../fonts/Hatter.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --page-width: 432px;
  --page-height: 768px;
  --accent: #6d1215;
  --accent-dark: #4e0d10;
  --paper: #ffffff;
  --ink: #6d1215;
  --gold: #c89f57;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Dekko", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(109, 18, 21, .08), transparent 34%),
    radial-gradient(circle at 85% 80%, rgba(200, 159, 87, .12), transparent 36%),
    #fcf8f3;
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.scene {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 60px;
  overflow: hidden;
  box-sizing: border-box;
}

.book-wrapper {
  width: calc(var(--page-width) * 2);
  height: var(--page-height);
  flex: 0 0 auto;
  transform-origin: top center;
  will-change: transform;
}

#book { width: 100%; height: 100%; }

.page {
  position: relative;
  width: var(--page-width);
  height: var(--page-height);
  overflow: hidden;
  background: var(--paper);
}

.page-art, .interactive-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.interactive-art { z-index: 2; }

.guest-block {
  position: absolute;
  z-index: 3;
  top: 21.5%;
  left: 8%;
  width: 84%;
  height: 6.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.guest-name {
  margin: 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 23px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

.page-ig-btn {
  position: absolute;
  z-index: 4;
  width: 6.11%;
  height: 3.44%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.page-ig-btn:hover {
  transform: scale(1.22);
}
.page-ig-btn:active {
  transform: scale(0.92);
}
.page-ig-btn:focus-visible {
  outline: 3px solid #6d1215;
  outline-offset: 2px;
}
.page-ig-btn img,
.page-ig-btn svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.page-ig-btn--bride {
  top: 50.78%;
  left: 63.06%;
  width: 4.72%;
  height: 2.81%;
}
.page-ig-btn--groom {
  top: 75.62%;
  left: 30%;
  width: 5%;
  height: 2.81%;
}
.page-ig-btn::before {
  content: '';
  position: absolute;
  inset: -12px;
}

.page-pill-btn {
  position: absolute;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6d1215;
  color: #ffffff;
  border: 0;
  border-radius: 999px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(109, 18, 21, 0.25);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.page-pill-btn:hover {
  background: #560e11;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 14px rgba(86, 14, 17, 0.35);
}
.page-pill-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 6px rgba(86, 14, 17, 0.25);
}
.page-pill-btn:focus-visible {
  outline: 3px solid #6d1215;
  outline-offset: 2px;
}
.page-pill-btn::after {
  content: '';
  position: absolute;
  inset: -10px;
}
.page-pill-btn--maps {
  top: 70.15%;
  left: 48.89%;
  width: 32.22%;
  height: 3.2%;
  transform: rotate(-9deg);
}
.page-pill-btn--maps-reception2 {
  top: 59%;
  left: 38%;
}
.page-pill-btn--maps:hover {
  transform: rotate(-9deg) translateY(-2px) scale(1.02);
}
.page-pill-btn--maps:active {
  transform: rotate(-9deg) scale(0.97);
}
.page-pill-btn--rsvp {
  top: 32.50%;
  left: 33.89%;
  width: 32.50%;
  height: 2.75%;
}
.page-pill-btn--wishes {
  top: 82.34%;
  left: 33.89%;
  width: 32.50%;
  height: 2.75%;
}
.page-pill-btn--gift {
  top: 51.72%;
  left: 33.89%;
  width: 32.22%;
  height: 2.75%;
}


.gallery-grid {
  position: absolute;
  left: 9.44%;
  top: 23.4%;
  width: 81.11%;
  height: 59.85%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  column-gap: 4.3%;
  row-gap: 3%;
  z-index: 4;
}

.gallery-photo {
  position: relative;
  width: 100%;
  height: 90%;
  align-self: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  overflow: hidden;
  display: block;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.gallery-photo:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 6;
}

.gallery-photo:active {
  transform: scale(0.96);
}

.gallery-photo:focus-visible {
  outline: 3px solid #6d1215;
  outline-offset: 2px;
  z-index: 6;
}

.gallery-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Bring the middle-right gallery photo slightly closer to match the intended framing. */
.gallery-photo[data-gallery-index="5"] img {
  transform: scale(1.3);
}

.controls {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(109, 18, 21, .2);
  border-radius: 999px;
  background: rgba(255, 252, 238, .94);
  box-shadow: 0 6px 20px rgba(78, 13, 16, .16);
  backdrop-filter: blur(10px);
}

.control-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  color: #fffef8;
  background: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, box-shadow .2s ease, transform .15s ease;
}

.control-button:active { transform: scale(.92); }
.control-button:hover { background: var(--accent-dark); }
.control-button:disabled { cursor: not-allowed; opacity: .4; background: #c9a9a9; }
.page-counter { min-width: auto; padding: 0 5px; text-align: center; font: 700 12px/1 system-ui, sans-serif; color: var(--accent-dark); white-space: nowrap; }
.music-button { padding-bottom: 0; font-size: 15px; }
.music-button.is-playing { box-shadow: 0 0 0 3px rgba(109, 18, 21, .3); }

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 4, 4, .68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: min(88vh, 780px);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(60, 5, 5, .4);
}

.modal-close {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
  font: 300 24px/1 system-ui, sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s ease, transform .18s ease;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.38);
  transform: scale(1.08);
}

.modal-header {
  padding: 28px 44px 22px;
  text-align: center;
  color: #ffffff;
  background: #6d1215;
}

.modal-header p {
  margin: 0 0 5px;
  font-family: 'Dekko', cursive, sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .24em;
  opacity: .92;
}
.modal-header h2 {
  margin: 0;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 700;
}
.modal-header span {
  display: block;
  margin-top: 6px;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  opacity: .92;
}

#rsvp-form, #wish-form {
  display: grid;
  gap: 15px;
  padding: 24px 26px 18px;
}
.field {
  display: grid;
  gap: 6px;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #6d1215;
}
.field small { font-weight: 400; color: #777; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1.5px solid #ecd8d8;
  border-radius: 12px;
  padding: 11px 14px;
  color: #222222;
  background: #fdfbfb;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input::placeholder, .field textarea::placeholder {
  color: #a89494;
  font-family: 'Dekko', cursive, sans-serif;
}
.field textarea { resize: vertical; min-height: 92px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #6d1215;
  box-shadow: 0 0 0 3px rgba(109, 18, 21, .15);
  background: #ffffff;
}

.attendance-field { margin: 0; padding: 0; border: 0; }
.attendance-field legend {
  margin-bottom: 7px;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #6d1215;
}
.attendance-field label { display: inline-flex; align-items: center; margin: 0 10px 7px 0; cursor: pointer; }
.attendance-field input { position: absolute; opacity: 0; }
.attendance-field span {
  padding: 9px 16px;
  border: 1.5px solid #ecd8d8;
  border-radius: 999px;
  background: #fff;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  transition: all .18s ease;
}
.attendance-field input:checked + span {
  border-color: #6d1215;
  color: #fff;
  background: #6d1215;
  box-shadow: 0 2px 8px rgba(109, 18, 21, 0.25);
}

.primary-button, .secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 10px 24px;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.primary-button {
  color: #fff;
  background: #6d1215;
  box-shadow: 0 4px 12px rgba(109, 18, 21, 0.28);
}
.primary-button:hover {
  background: #4e0d10;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(109, 18, 21, 0.38);
}
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.secondary-button {
  color: #6d1215;
  border: 1.5px solid #6d1215;
  background: transparent;
  width: 100%;
  margin-top: 12px;
}
.secondary-button:hover {
  background: rgba(109, 18, 21, .08);
}
.form-message { min-height: 18px; margin: -4px 0; font-family: 'Dekko', cursive, sans-serif; font-size: 14px; font-weight: 700; color: #16713c; }
.form-message.error { color: #6d1215; }

.wishes-section {
  padding: 6px 26px 28px;
  border-top: 1px solid #f4e6e6;
  margin-top: 8px;
}
.wishes-section h3 {
  margin: 14px 0 14px;
  color: #6d1215;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 25px;
  font-weight: 700;
}
.wishes-list { display: grid; gap: 10px; }
.wish-item {
  padding: 12px 16px;
  border: 1px solid #f2e2e2;
  border-left: 4px solid #6d1215;
  border-radius: 12px;
  background: #fffafa;
  box-shadow: 0 2px 6px rgba(109, 18, 21, 0.04);
}
.wish-item strong {
  display: block;
  color: #6d1215;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
  font-weight: 700;
}
.wish-item p {
  margin: 4px 0 6px;
  white-space: pre-wrap;
  line-height: 1.4;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 15px;
  color: #333333;
}
.wish-item time {
  color: #998080;
  font: 11px/1 system-ui, sans-serif;
}
.empty-state {
  margin: 0;
  padding: 24px 16px;
  text-align: center;
  color: #8c7272;
  font-family: 'Dekko', cursive, sans-serif;
  font-size: 16px;
}

.account-panel { overflow: hidden; }
.account-options { display: grid; gap: 14px; padding: 24px; background: #fbf6ef; }
.account-option {
  display: grid;
  gap: 5px;
  padding: 18px 20px;
  border: 1.5px solid #f0dcd8;
  border-radius: 18px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf9, #fff6ee);
  box-shadow: 0 6px 18px rgba(109, 18, 21, .08);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.account-option:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(109, 18, 21, .16);
}
.account-option:active { transform: scale(.98); }
.account-option:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.account-top { display: flex; align-items: center; gap: 10px; }
.account-top strong {
  flex: 1;
  font: 800 14px/1.2 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.account-option .account-logo { height: 30px; width: auto; max-width: 120px; object-fit: contain; }
.account-gift-icon { color: var(--accent); flex-shrink: 0; }
.account-copy-icon { color: var(--accent); opacity: .5; flex-shrink: 0; transition: opacity .18s ease, transform .18s ease; }
.account-option:hover .account-copy-icon { opacity: 1; transform: scale(1.1); }
.account-option .account-number {
  font: 700 23px/1.35 'Courier New', Courier, monospace;
  letter-spacing: .03em;
  color: #3d0a0d;
}
.account-option small { font: 13px/1.4 system-ui, sans-serif; color: #7a6a6a; }
.account-option .account-address {
  font: 600 16px/1.5 system-ui, sans-serif;
  letter-spacing: 0;
  color: #3d0a0d;
}

.lightbox { grid-template-columns: minmax(44px, 1fr) minmax(0, 900px) minmax(44px, 1fr); }
.lightbox figure { position: relative; margin: 0; min-height: 150px; max-width: 100%; max-height: 90vh; display: grid; place-items: center; gap: 8px; }
.lightbox figure img { max-width: 100%; max-height: calc(90vh - 34px); display: block; object-fit: contain; border-radius: 7px; box-shadow: 0 18px 55px rgba(0,0,0,.4); transition: opacity .18s ease; }
.lightbox figure.is-loading::before { content: ''; position: absolute; z-index: 2; top: 50%; left: 50%; width: 34px; height: 34px; margin: -24px 0 0 -17px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: lightbox-spin .8s linear infinite; }
.lightbox figure.is-loading img { opacity: .2; }
.lightbox figcaption { color: #fff; font: 600 13px/1.2 system-ui, sans-serif; }
.lightbox-close { position: fixed; top: 14px; right: 16px; }
.lightbox-nav { width: 46px; height: 54px; justify-self: center; border: 0; border-radius: 12px; color: #fff; background: rgba(109, 18, 21, .9); font: 36px/1 system-ui, sans-serif; cursor: pointer; }
@keyframes lightbox-spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  z-index: 2000;
  left: 50%;
  bottom: 84px;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 18px);
  padding: 11px 17px;
  border-radius: 999px;
  color: #fff;
  background: #2e201c;
  font: 600 13px/1.2 system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .scene {
    gap: 10px;
    padding: max(16px, env(safe-area-inset-top)) 2px max(16px, env(safe-area-inset-bottom));
    justify-content: center;
  }
  .book-wrapper { width: var(--page-width); }
  .controls {
    position: static;
    left: auto;
    bottom: auto;
    flex: 0 0 auto;
    transform: none;
    padding: 4px 6px;
    gap: 6px;
    background: #fff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .control-button { width: 34px; height: 34px; font-size: 22px; }
  .page-counter { min-width: auto; font-size: 12px; }
  .music-button { font-size: 16px; }
  .modal {
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  }
  .modal-panel { max-height: 100%; border-radius: 16px; }
  .modal-header { padding: 26px 42px 20px; }
  #rsvp-form, #wish-form, .wishes-section { padding-left: 18px; padding-right: 18px; }
  .lightbox { grid-template-columns: 44px minmax(0, 1fr) 44px; padding: 8px; }
  .lightbox-nav { width: 38px; height: 48px; }
}

@media (max-width: 370px) {
  .controls { gap: 5px; padding: 3px 5px; }
  .control-button { width: 32px; height: 32px; font-size: 20px; }
  .page-counter { min-width: auto; font-size: 11px; }
  .music-button { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
