:root {
  --bg: #000000;
  --fg: #fbfbfb;
  --fg-soft: #dfdfdf;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

.scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  isolation: isolate;
}

.background-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(0.65) brightness(0.9) blur(4px);
  transform: scale(1.06);
  z-index: 0;
}

.dark-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: rgba(0, 0, 0, 0.34);
}

.dither-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.46;
  background-color: rgba(255, 255, 255, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23FFFFFF' fill-opacity='0.4' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");
  background-size: 4px 4px;
  mix-blend-mode: screen;
}

.memorial {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  min-height: 100vh;
  padding: 0 1.5rem 4.5rem;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
}

.hero-intro {
  width: min(48rem, 96vw);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.memorial h1,
.memorial .dates {
  margin: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.38), 0 10px 20px rgba(0, 0, 0, 0.25);
}

.memorial h1 {
  font-size: clamp(2.4rem, 10vw, 7rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 0.95;
  padding: 0;
  animation: gentle-breathe 6s ease-in-out infinite;
}

.name-with-check {
  display: inline-flex;
  align-items: center;
  gap: 0.14em;
}

.username-check {
  width: 0.8em;
  height: 0.8em;
  flex: 0 0 auto;
  transform: translateY(0.02em);
}

.memorial .dates {
  margin-top: 0.9rem;
  font-size: clamp(0.95rem, 2.6vw, 1.5rem);
  color: var(--fg-soft);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.reveal-guestbook-button {
  margin-top: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.9rem 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.reveal-guestbook-button:hover,
.reveal-guestbook-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.guestbook-area {
  width: min(40rem, 92vw);
  margin-top: 0;
}

.guestbook-area[hidden] {
  display: none !important;
}

.guestbook {
  width: 100%;
  margin-top: 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 0.4rem;
  text-align: left;
  backdrop-filter: blur(2px);
}

.guestbook h2 {
  margin: 0 0 0.7rem;
  font-size: clamp(0.95rem, 2.3vw, 1.1rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
}

.guestbook-form {
  display: grid;
  gap: 0.55rem;
}

.guestbook-form input,
.guestbook-form textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
}

.guestbook-form textarea {
  resize: vertical;
  min-height: 4.5rem;
  max-height: 10rem;
}

.guestbook-form input::placeholder,
.guestbook-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.guestbook-form input:focus-visible,
.guestbook-form textarea:focus-visible {
  outline: 2px solid rgba(169, 112, 255, 0.85);
  outline-offset: 1px;
}

.guestbook-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.guestbook-actions button {
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.5rem 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
}

.guestbook-actions button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.guestbook-actions button:hover,
.guestbook-actions button:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

#guestbook-status {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.84);
}

#guestbook-status[data-state="error"] {
  color: #ffb5b5;
}

.guestbook-entries {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  max-height: none;
  overflow: visible;
}

.guestbook-entry {
  border: 1px solid rgba(255, 255, 255, 0.17);
  background: rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.guestbook-entry-empty {
  padding: 0.55rem 0.65rem;
}

.guestbook-entry-body {
  display: flex;
  align-items: stretch;
}

.guestbook-entry.has-image .guestbook-entry-body {
  min-height: 7.8rem;
}

.guestbook-entry-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.65rem;
}

.guestbook-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.guestbook-entry-name {
  font-size: 0.85rem;
  font-weight: 800;
}

.guestbook-entry-date {
  font-size: 0.72rem;
  opacity: 0.8;
}

.guestbook-entry-message {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1 1 auto;
}

.guestbook-entry-media {
  flex: 0 0 clamp(5.8rem, 18vw, 8.8rem);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: flex-start;
  padding: 0.45rem;
}

.guestbook-entry-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
}

.guestbook-image-button {
  display: flex;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: auto;
  padding: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.guestbook-image-button:hover,
.guestbook-image-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.guestbook-thumbnail {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  max-height: none;
  object-fit: cover;
  object-position: center;
  filter: grayscale(1);
}

.guestbook-image-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: auto;
  border: 0;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.95);
  padding: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

.guestbook-image-fallback:hover,
.guestbook-image-fallback:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 3.2rem 1rem 1rem;
}

.image-lightbox-close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.7);
  color: var(--fg);
  padding: 0.4rem 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.image-lightbox-close:hover,
.image-lightbox-close:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.image-lightbox-image {
  max-width: min(94vw, 72rem);
  max-height: min(84vh, 58rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.26);
  filter: grayscale(1);
}

.image-lightbox[hidden] {
  display: none !important;
}

.guestbook-delete-button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.56);
  color: rgba(255, 255, 255, 0.9);
  padding: 0.28rem 0.46rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
}

.guestbook-delete-button:hover,
.guestbook-delete-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.guestbook-delete-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.admin-panel {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.9rem;
  background: rgba(0, 0, 0, 0.58);
  border: 1px solid rgba(169, 112, 255, 0.4);
  border-radius: 0.4rem;
  text-align: left;
  backdrop-filter: blur(2px);
}

.admin-page {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.2rem;
}

.admin-shell {
  width: min(56rem, 96vw);
}

.admin-shell h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(1.35rem, 4.8vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.38), 0 10px 20px rgba(0, 0, 0, 0.25);
}

.admin-shell .admin-panel {
  margin-top: 1rem;
}

.admin-panel h2 {
  margin: 0 0 0.7rem;
  font-size: clamp(0.9rem, 2.2vw, 1.05rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
}

.admin-auth {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-auth input {
  flex: 1 1 13rem;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.52rem 0.64rem;
  font: inherit;
  font-size: 0.84rem;
}

.admin-auth input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.admin-auth input:focus-visible {
  outline: 2px solid rgba(169, 112, 255, 0.85);
  outline-offset: 1px;
}

.admin-auth button,
.admin-delete-button {
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.45rem 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font: inherit;
  font-weight: 700;
  font-size: 0.7rem;
  cursor: pointer;
}

.admin-auth button:hover,
.admin-auth button:focus-visible,
.admin-delete-button:hover,
.admin-delete-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.admin-delete-button {
  border-color: rgba(255, 140, 140, 0.8);
  color: #ffd3d3;
}

.admin-delete-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

#admin-status {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.84);
}

#admin-status[data-state="error"] {
  color: #ffb5b5;
}

.admin-entries {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  max-height: none;
  overflow: visible;
}

.admin-entry {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.44);
  padding: 0.55rem 0.65rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
}

.admin-entry-meta {
  min-width: 0;
}

.admin-entry-meta strong {
  display: inline-block;
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.admin-entry-meta p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.9;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.admin-delete-button {
  align-self: start;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
 }

.enable-audio {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 4;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.56);
  color: var(--fg);
  padding: 0.55rem 1rem 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  cursor: pointer;
}

.enable-audio:hover,
.enable-audio:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

@keyframes gentle-breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@media (max-width: 640px) {
  .memorial {
    padding-bottom: 5.8rem;
  }

  .memorial h1 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .memorial .dates {
    letter-spacing: 0.16em;
    font-size: clamp(0.82rem, 3.6vw, 1rem);
  }

  .guestbook {
    padding: 0.75rem;
  }

  .guestbook-entry.has-image .guestbook-entry-body {
    min-height: 6.8rem;
  }

  .guestbook-entry-media {
    flex-basis: clamp(4.8rem, 24vw, 6.2rem);
  }

  .reveal-guestbook-button {
    padding: 0.72rem 1.2rem;
    font-size: 0.9rem;
  }

  .admin-panel {
    margin-top: 0.7rem;
    padding: 0.7rem;
  }

  .admin-entries {
    max-height: none;
    overflow: visible;
  }

  .admin-entry {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .admin-delete-button {
    justify-self: end;
  }

  .enable-audio {
    bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
