*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  background: #02040c;
  color: #ffffff;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html {
  height: var(--app-height, 100dvh);
}

body {
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
}

#scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: block;
}

#vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(1, 2, 8, 0.55) 100%);
  z-index: 2;
}

#veil {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  background: #000;
  z-index: 8;
  opacity: 1;
  transition: opacity 2.8s ease;
  pointer-events: none;
}

#veil.gone {
  opacity: 0;
}

#letter {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 12, 0.15);
  opacity: 1;
  transition: opacity 0.55s ease;
}

#letter.hidden {
  opacity: 0;
  pointer-events: none;
}

.glass {
  position: relative;
  width: min(86vw, 400px);
  overflow: hidden;
  border-radius: 28px;
  transform: scale(0.94) translateY(12px);
  transition:
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.75s ease;

  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 24px 64px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

@media (min-width: 768px) {
  .glass {
    width: min(68vw, 620px);
    border-radius: 32px;
  }
}

#letter:not(.hidden) .glass {
  transform: scale(1) translateY(0);
}

.glass-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

.glass-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.05) 30%,
      transparent 55%);
  opacity: 0.4;
}

.glass-edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    inset 0 1px 24px rgba(255, 255, 255, 0.1),
    inset 0 -10px 28px rgba(0, 0, 0, 0.14);
}

.letter-body {
  position: relative;
  z-index: 2;
  padding: 36px 32px 34px;
  user-select: text;
}

@media (min-width: 768px) {
  .letter-body {
    padding: 40px 44px 38px;
  }
}

.salutation {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.4rem, 4.5vw, 1.75rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 50, "WONK" 1;
  color: #ffffff;
  margin-bottom: 1.25rem;
}

.name {
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

.body-text {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(0.78rem, 2.8vw, 0.92rem);
  font-weight: 300;
  line-height: 1.75;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 1.5rem;
}

.poem {
  margin: 0;
  padding: 1.35rem 0 0;
  border: none;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "SOFT" 50, "WONK" 1;
  font-size: clamp(1rem, 3.6vw, 1.22rem);
  line-height: 1.7;
  text-align: left;
  color: #ffffff;
}

#close-letter {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

#close-letter:hover {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

#audio-btn {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 7;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: pointer;
  display: grid;
  place-items: center;
}

#audio-btn svg {
  width: 20px;
  height: 20px;
}

#audio-btn .icon-playing,
#audio-btn.is-playing .icon-muted {
  display: none;
}

#audio-btn.is-playing .icon-playing {
  display: block;
}

@media (prefers-reduced-motion: reduce) {

  .glass,
  #veil,
  #letter {
    animation: none;
    transition: none;
  }
}