:root {
  --accent: #8d8274;
  --page: #ebe8e3;
  --paper: #fffdf9;
  --paper-soft: #f8f5ef;
  --ink: #171412;
  --muted: #6f675f;
  --line: #e2d9ce;
  --shadow: 0 28px 80px rgba(42, 36, 30, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scrollbar-gutter: stable;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #4fb4d8 rgba(79, 180, 216, 0.12);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(79, 180, 216, 0.12);
}

*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: #4fb4d8;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 0 0 82px;
  background:
    radial-gradient(circle at 50% -10%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 36rem),
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 20%, #f0eee9) 0%, #d8d6d2 100%);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  touch-action: manipulation;
}

a {
  color: inherit;
}

.material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
}

.memorial-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.memorial-card {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 74%, white);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 6%, #fff 0%, var(--paper) 46%, var(--paper-soft) 100%);
  box-shadow: var(--shadow);
}

.portrait-section {
  display: grid;
  justify-items: center;
  padding: clamp(28px, 7vw, 48px) 18px 0;
}

.portrait-frame {
  position: relative;
  width: min(306px, 76vw);
  aspect-ratio: 3 / 4;
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 20px 42px rgba(32, 28, 24, 0.24);
  object-fit: cover;
}

.portrait-frame:not(.portrait-fallback)::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  border-radius: 0 0 16px 16px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      color-mix(in srgb, var(--accent) 38%, transparent) 28%,
      rgba(255, 255, 255, 0.96) 48%,
      color-mix(in srgb, var(--accent) 58%, white) 58%,
      transparent 100%
    );
  background-size: 180px 100%;
  box-shadow:
    0 0 14px color-mix(in srgb, var(--accent) 34%, transparent),
    0 -4px 18px color-mix(in srgb, var(--accent) 16%, transparent);
  mix-blend-mode: screen;
  pointer-events: none;
  transform: translateX(-95%);
  animation: portrait-bottom-shine 8.8s ease-in-out infinite;
}

.portrait-fallback {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  isolation: isolate;
}

.portrait-fallback::before,
.portrait-fallback::after,
.portrait-fallback span {
  content: "";
  grid-area: 1 / 1;
  display: block;
  width: min(78%, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
}

.portrait-fallback::before {
  padding: 8px;
  background:
    conic-gradient(
      from 0deg,
      color-mix(in srgb, var(--accent) 52%, white),
      color-mix(in srgb, var(--accent) 76%, white) 18%,
      rgba(255, 255, 255, 0.92) 26%,
      color-mix(in srgb, var(--accent) 62%, white) 34%,
      color-mix(in srgb, var(--accent) 42%, transparent) 62%,
      color-mix(in srgb, var(--accent) 52%, white)
    );
  box-shadow:
    0 0 18px color-mix(in srgb, var(--accent) 28%, transparent),
    0 0 48px color-mix(in srgb, var(--accent) 20%, transparent);
  filter: blur(0.25px);
  animation: portrait-ring-shine 9s linear infinite;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.portrait-fallback::after {
  width: min(60%, 178px);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  filter: blur(8px);
  opacity: 0.75;
}

.portrait-fallback span {
  width: min(44%, 132px);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 12%, transparent), transparent 68%);
  filter: blur(16px);
  opacity: 0.9;
}

@keyframes portrait-ring-shine {
  to {
    transform: rotate(360deg);
  }
}

@keyframes portrait-bottom-shine {
  0%,
  8% {
    transform: translateX(-110%) scaleX(0.7);
    opacity: 0;
  }

  15% {
    transform: translateX(-42%) scaleX(1.08);
    opacity: 0.72;
  }

  23% {
    transform: translateX(-18%) scaleX(0.86);
    opacity: 0.42;
  }

  39% {
    transform: translateX(34%) scaleX(1.18);
    opacity: 0.82;
  }

  47% {
    transform: translateX(18%) scaleX(0.72);
    opacity: 0.34;
  }

  61% {
    transform: translateX(96%) scaleX(1);
    opacity: 0.68;
  }

  62%,
  100% {
    transform: translateX(115%) scaleX(0.82);
    opacity: 0;
  }
}

.identity {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 22px 0;
  text-align: center;
}

.memorial-title {
  max-width: 640px;
  margin: 0;
  font-family: "Noto Serif", Georgia, serif;
  font-size: clamp(30px, 7vw, 48px);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.life-dates {
  margin: 0;
  color: var(--muted);
  font-family: "Noto Serif", Georgia, serif;
  font-size: 15px;
  font-weight: 600;
}

.symbol-block {
  display: grid;
  justify-items: center;
  padding: 24px 16px 8px;
}

.symbol-block img {
  display: block;
  width: min(300px, 76vw);
  max-height: 320px;
  object-fit: contain;
}

.audio-panel,
.funeral-panel,
.message-section,
.curation-section,
.support-section {
  width: min(100% - 32px, 560px);
  margin: 22px auto 0;
}

.message-section {
  padding-inline: 6px;
}

.audio-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

audio {
  width: 100%;
}

.funeral-panel {
  padding: 18px;
  border-block: 1px solid var(--line);
  text-align: center;
}

.funeral-panel h2,
.message-heading {
  margin: 10px 0 18px;
  font-family: "Noto Serif", Georgia, serif;
  font-size: clamp(25px, 6vw, 34px);
  line-height: 1.25;
}

.funeral-panel p {
  margin: 0;
  color: var(--muted);
}

.message-heading {
  text-align: center;
  overflow-wrap: anywhere;
}

.markdown-body {
  color: #24201d;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 18px;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.markdown-body p:first-child,
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.25rem auto;
  border-radius: 12px;
}

.media-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.5rem 0;
  overflow: hidden;
  border-radius: 14px;
  background: #111;
}

.media-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.curation-section {
  display: grid;
  gap: 16px;
  padding: 24px 0 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.curation-block {
  display: grid;
  gap: 5px;
  justify-items: center;
}

.curation-block img {
  display: block;
  width: min(140px, 42vw);
  max-height: 74px;
  object-fit: contain;
}

.curation-block strong {
  color: var(--ink);
  font-size: 15px;
}

.curation-name-link {
  text-decoration-color: color-mix(in srgb, var(--accent) 58%, transparent);
  text-underline-offset: 4px;
}

.curation-name-link:hover,
.curation-name-link:focus-visible {
  color: var(--ink);
  text-decoration-color: var(--accent);
}

.curation-block span,
.curation-block a {
  font-size: 13px;
}

.curation-block .section-label {
  color: color-mix(in srgb, var(--muted) 46%, white);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.support-section {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 4px 0 64px;
}

.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.qrcode-link {
  display: grid;
  width: 146px;
  aspect-ratio: 1;
  place-items: center;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, white);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 30px rgba(32, 28, 24, 0.08);
}

.qrcode-link img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.candle {
  position: fixed;
  right: 0;
  bottom: 78px;
  left: 0;
  z-index: 1500;
  pointer-events: none;
  animation: blink 0.1s infinite;
}

.flame-out,
.flame-in {
  position: relative;
  width: 20px;
  height: 100px;
  margin: 0 auto;
  transform-origin: 50% 90%;
  pointer-events: none;
}

.flame-out {
  animation: move 1s, move-left 1s;
  opacity: 0;
  transition: opacity .12s;
  transition-delay: 0s;
}

.flame-in {
  animation: move 3s infinite, move-left 3s infinite;
  opacity: 1;
  transition: opacity .5s;
  transition-delay: .5s;
}

.flame-in::before {
  content: "";
  position: absolute;
  left: 50%;
  width: 0;
  height: 10px;
  box-shadow: 0 -14px 10px 8px white, 0 -10px 10px 8px rgba(255, 215, 0, 0.7), 0 -3px 10px 8px rgba(255, 106, 0, 0.7);
}

.flame-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  border-top-left-radius: 500%;
  border-top-right-radius: 500%;
  border-bottom-left-radius: 50px;
  border-bottom-right-radius: 50px;
  background: white;
  transform: skewY(-10deg);
  box-shadow: 0 0 0 3px white, 0 -20px 1px 4px white, 0 -25px 2px 3px gold, 0 -30px 5px 4px #ff6a00, 0 0 150px 10px #ff6a00, 0 -10px 2px 4px white, 0 -5px 3px 3px white;
  animation: flame-up 4s infinite;
}

.flame-shadows {
  position: absolute;
  top: 0;
  left: 10%;
  width: 1px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 5px 20px 15px gold, 0 0 100px 20px #ff6a00, 0 15px 50px 15px #ff6a00, 5px 30px 5px 13px #ff6a00, 5px 50px 5px 13px #ff6a00, 0 75px 50px 30px #ececec;
}

.flame-bottom {
  position: absolute;
  bottom: 0;
  left: 9px;
  width: 1px;
  height: 8px;
  border-radius: 1%;
  background: #2c2b39;
  box-shadow: 0 6px 10px 12px rgba(60, 76, 125, 0.3), 0 0 4px 8px #2c2b39, 0 -12px 10px 8px rgba(255, 106, 0, 0.5), 0 5px 7px 12px #2c2b39, 0 -3px 10px 12px #2c2b39, 5px -10px 10px 5px red, 0 -15px 10px 10px gold, 5px -25px 10px 5px gold, 0 2px 5px 10px #30537d, 0 -2px 2px 14px #76daff, 0 2px 10px 12px #76daff;
  transform: scale(0.9);
}

.candle-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1600;
  display: flex;
  justify-content: center;
  padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.candle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 48px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

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

.candle-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 11%, var(--paper));
}

.dialog-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.cookie-button {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 1610;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.cookie-dialog {
  position: fixed;
  inset: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
  scrollbar-gutter: stable;
}

.cookie-dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cookie-dialog h2 {
  margin: 0 0 8px;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 22px;
}

.cookie-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
}

@keyframes move {
  0% { transform: skewX(2deg) skewY(5deg); }
  50% { transform: skewX(-2deg) skewY(0deg); }
  100% { transform: skewX(2deg) skewY(5deg); }
}

@keyframes move-left {
  50% { transform: skewX(3deg); }
}

@keyframes flame-up {
  50% {
    box-shadow: 0 0 0 3px white, 0 -38px 1px 2px white, 0 -41px 2px 3px gold, 0 -50px 5px 4px #ff6a00, 0 0 150px 10px #ff6a00, 0 -10px 2px 4px white, 0 -5px 3px 3px white;
  }
}

@keyframes blink {
  50% { opacity: 0.95; }
}

@media (min-width: 900px) {
  body {
    padding-top: 16px;
  }

  .memorial-shell {
    padding-top: 0;
  }
}

@media (max-width: 520px) {
  body {
    background: var(--paper);
  }

  .memorial-shell {
    padding: 0 0 34px;
  }

  .memorial-card {
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .portrait-section {
    padding-top: 24px;
  }

  .portrait-section:has(.portrait-fallback) {
    padding-top: 12px;
  }

  .portrait-fallback {
    width: min(220px, 58vw);
    aspect-ratio: 1;
    margin-top: 30px;
  }

  .portrait-fallback::before {
    padding: 7px;
  }

  .portrait-section:has(.portrait-fallback) + .identity {
    padding-top: 14px;
  }

  .audio-panel,
  .funeral-panel,
  .message-section,
  .curation-section,
  .support-section {
    width: min(100% - 28px, 560px);
  }

  .message-section {
    padding-inline: 10px;
  }

  .markdown-body {
    font-size: 17px;
  }
}

@media (max-width: 380px) {
  .portrait-section {
    padding: 0;
  }

  .portrait-frame {
    width: 100%;
    aspect-ratio: 5 / 6;
    border-radius: 0;
  }

  .portrait-frame img {
    border-width: 0 0 4px;
    border-radius: 0;
    box-shadow: none;
  }

  .portrait-frame:not(.portrait-fallback)::after {
    height: 4px;
    border-radius: 0;
    background-size: 52vw 100%;
  }

  .portrait-fallback {
    width: min(210px, 62vw);
    aspect-ratio: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
