@font-face {
  font-family: "Caveat";
  src: url("./fonts/caveat-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Caveat";
  src: url("./fonts/caveat-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  background: #090a12;
  color: #fff2ff;
}

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

body {
  margin: 0;
  overflow: hidden;
}

.scene {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, #121321, #090a12 80%);
}

button { color: inherit; }

.portrait {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.portrait:disabled { cursor: default; }
.portrait[hidden] { display: none; }

.portrait:focus-visible {
  outline: 2px solid #ddc5f1;
  outline-offset: -5px;
}

.portrait canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.final-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.035);
  pointer-events: none;
  transition: opacity 1000ms ease-out, transform 1600ms ease-out;
}

.final-image.is-visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.reveal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 7vw max(24px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transition: opacity 850ms ease-out;
  background: radial-gradient(ellipse 75% 45% at center, #0809128f 0%, #08091259 42%, #08091216 75%, transparent);
}

.reveal.is-visible { opacity: 1; }

.reveal p {
  max-width: 24ch;
  margin: 0;
  transform: translateY(9px);
  color: #fff2ff;
  font-family: "Caveat", cursive;
  font-size: clamp(2.35rem, 6.7vw, 6.5rem);
  font-weight: 500;
  line-height: 1.04;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 2px 22px #070712, 0 1px 3px #000;
  transition: transform 850ms ease-out;
}

.reveal.is-visible p { transform: translateY(0); }

.sound {
  position: fixed;
  z-index: 1;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 1px solid #c4a6dc6b;
  border-radius: 50%;
  background: #0e0d19e8;
  color: #e1cbed;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sound:hover, .sound[aria-pressed="true"] { background: #251934; }

.sound:focus-visible {
  outline: 2px solid #ddc5f1;
  outline-offset: 3px;
}

.equalizer {
  display: inline-flex;
  height: 20px;
  gap: 3px;
  align-items: center;
  opacity: .72;
}

.equalizer i {
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

.equalizer i:nth-child(2) { height: 15px; }
.equalizer i:nth-child(3) { height: 18px; }
.equalizer i:nth-child(4) { height: 11px; }

.sound[aria-pressed="true"] .equalizer { opacity: 1; }
.sound[aria-pressed="true"] i { animation: pulse 850ms ease-in-out infinite alternate; }
.sound[aria-pressed="true"] i:nth-child(2) { animation-delay: -220ms; }
.sound[aria-pressed="true"] i:nth-child(3) { animation-delay: -570ms; }
.sound[aria-pressed="true"] i:nth-child(4) { animation-delay: -360ms; }

@keyframes pulse { to { transform: scaleY(.42); } }

@media (max-aspect-ratio: 3/4) {
  .reveal {
    background: radial-gradient(ellipse 100% 31% at center, #080912ab, #08091253 58%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal p, .final-image { transition: none; }
  .sound[aria-pressed="true"] i { animation: none; }
}
