:root {
  color-scheme: light;
  --ink: #241d19;
  --muted: #74685f;
  --paper: #f7f3ec;
  --panel: #fffaf2;
  --line: rgba(36, 29, 25, 0.14);
  --accent: #6d7f73;
  --accent-dark: #42564a;
  --gold: #b8965d;
  --shadow: 0 22px 70px rgba(36, 29, 25, 0.16);
  font-family: Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 50% 10%, #fffaf3 0, var(--paper) 38%, #e9e1d5 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.home-page {
  overflow: hidden;
}

.home-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 56px);
}

.home-hero {
  width: min(980px, 100%);
  display: grid;
  justify-items: center;
  gap: 22px;
}

.hero-photo-frame {
  width: min(680px, 92vw);
  aspect-ratio: 4 / 3;
  padding: clamp(10px, 2vw, 18px);
  background: #fffdf8;
  border: 1px solid rgba(184, 150, 93, 0.35);
  box-shadow: var(--shadow);
}

.hero-photo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: linear-gradient(135deg, #e9e1d7, #fdf9ef);
}

.home-copy {
  text-align: center;
}

.memorial-name {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  font-weight: 400;
  line-height: 1;
}

.play-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}

.play-button,
.primary-button {
  color: #fffdf8;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 14px 32px rgba(66, 86, 74, 0.26);
}

.play-button {
  padding: 14px 34px;
  font-size: 1rem;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid currentColor;
}

.admin-link {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 250, 242, 0.82);
  border: 1px solid var(--line);
  text-decoration: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  backdrop-filter: blur(10px);
}

.admin-shell {
  min-height: 100vh;
}

.password-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.password-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: var(--shadow);
}

.password-form {
  margin-top: 24px;
  display: grid;
  gap: 12px;
  font-family: Arial, Helvetica, sans-serif;
}

.password-form label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.password-form input,
.photo-table input,
.photo-table select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fffdf8;
  font-family: Arial, Helvetica, sans-serif;
}

.form-error,
.save-status {
  min-height: 22px;
  color: #8c3d31;
  font-family: Arial, Helvetica, sans-serif;
}

.locked .admin-workspace {
  display: none;
}

.admin-workspace {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.admin-header h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.upload-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.82);
  box-shadow: 0 16px 48px rgba(36, 29, 25, 0.08);
}

.settings-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.82);
  box-shadow: 0 16px 48px rgba(36, 29, 25, 0.08);
}

.settings-panel h2 {
  font-size: 1.35rem;
}

.setting-field {
  display: grid;
  gap: 8px;
  min-width: 220px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.setting-input-group {
  white-space: nowrap;
}

.setting-field input[type='number'] {
  width: 96px;
}

.upload-help {
  color: var(--muted);
  font-size: 0.95rem;
}

.upload-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  text-align: center;
}

.upload-dropzone.dragging {
  border-color: #b17539;
  background: rgba(255, 248, 236, 0.98);
}

.upload-dropzone-text {
  color: var(--ink);
  font-weight: 700;
}

.primary-button,
.secondary-button {
  padding: 10px 18px;
}

.secondary-button {
  color: var(--accent-dark);
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid var(--line);
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.82);
  box-shadow: 0 16px 48px rgba(36, 29, 25, 0.1);
}

.photo-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-family: Arial, Helvetica, sans-serif;
}

.photo-table th,
.photo-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.photo-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8efe1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.photo-table tr.dragging {
  opacity: 0.45;
}

.drag-handle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-dark);
  background: #fffdf8;
  cursor: grab;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}

.thumbnail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.thumbnail-button:hover,
.thumbnail-button:focus-visible {
  outline: 2px solid rgba(109, 127, 115, 0.35);
  outline-offset: 3px;
}

.admin-thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  display: block;
  border-radius: 4px;
  background: #e6ded2;
}

.filename-cell {
  max-width: 360px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.photo-table input[type='radio'] {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent-dark);
}

.photo-table input[type='number'] {
  width: 82px;
  display: inline-block;
}

.seconds-label {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.player-page {
  margin: 0;
  background: #0e0d0b;
  overflow: hidden;
}

.slideshow-stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0e0d0b;
}

.slideshow-stage::after {
  content: attr(data-message);
  position: relative;
  z-index: 3;
  color: #f5efe5;
  font: 400 2rem Georgia, 'Times New Roman', serif;
}

.slide-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) scale(1);
  filter: none;
  clip-path: inset(0 0 0 0);
  transition: opacity var(--transition-duration, 1800ms) ease, transform var(--transition-duration, 1800ms) ease, filter var(--transition-duration, 1800ms) ease, clip-path var(--transition-duration, 1800ms) ease;
  will-change: opacity, transform, filter, clip-path;
}

.slide-image.preparing {
  transition: none;
}

.enter-fade-through {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) scale(1.015);
}

.enter-dissolve {
  opacity: 0;
  filter: saturate(0.72) contrast(0.94);
  transform: rotate(var(--photo-rotation, 0deg)) scale(1);
}

.enter-slide-left {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) translateX(16%) scale(1.01);
}

.enter-slide-right {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) translateX(-16%) scale(1.01);
}

.enter-slide-up {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) translateY(16%) scale(1.01);
}

.enter-zoom-in {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) scale(0.96);
}

.enter-zoom-out {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) scale(1.05);
}

.enter-blur-fade {
  opacity: 0;
  filter: blur(16px) saturate(0.82);
  transform: rotate(var(--photo-rotation, 0deg)) scale(1);
}

.enter-lift {
  opacity: 0;
  transform: rotate(var(--photo-rotation, 0deg)) translateY(3%) scale(0.985);
  filter: brightness(1.08);
}

.slide-image.active {
  z-index: 1;
  opacity: 1;
  transform: rotate(var(--photo-rotation, 0deg)) scale(1);
  filter: blur(0);
  clip-path: inset(0 0 0 0);
}

.slide-image.entering {
  z-index: 2;
}

.slide-image.leaving {
  z-index: 1;
  opacity: 0;
}

.player-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 62%, rgba(0, 0, 0, 0.28) 100%);
}

.photo-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 9, 8, 0.76);
}

.photo-modal-card {
  width: min(980px, 100%);
  max-height: 92vh;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(184, 150, 93, 0.35);
  border-radius: 16px;
  background: rgba(255, 250, 242, 0.98);
  box-shadow: var(--shadow);
}

.photo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-modal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-modal-action {
  min-height: 40px;
  padding: 8px 14px;
}

.photo-modal-close {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fffdf8;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.photo-modal-image {
  width: 100%;
  max-height: 78vh;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  background: linear-gradient(135deg, #ebe4d9, #fdfaf4);
  transform-origin: center center;
}

.player-home-button {
  position: fixed;
  right: 16px;
  bottom: 64px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  color: #f7f1e8;
  background: rgba(0, 0, 0, 0.36);
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
}

.fullscreen-button {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #f7f1e8;
  background: rgba(0, 0, 0, 0.36);
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
}

@media (max-width: 720px) {
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .password-card {
    padding: 24px;
  }
}
