:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #05070b;
  color: #f8f4fa;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 50% 43%, rgba(69, 17, 73, 0.18), transparent 31rem),
    radial-gradient(circle at 50% 110%, rgba(238, 73, 255, 0.06), transparent 26rem),
    #05070b;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: screen;
}

.experience {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 480px;
  isolation: isolate;
}

#heart-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.heart-message {
  position: absolute;
  margin: 0;
  color: #fff2ff;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.035em;
  white-space: nowrap;
  text-shadow:
    0 0 2px #ffffff,
    0 0 5px #ffd1ff,
    0 0 11px #fa8bff,
    0 0 22px #f052ffd9,
    0 0 42px #dc36f58c,
    0 0 64px #c72dea40;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
}

.topline {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(245, 235, 247, 0.36);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  user-select: none;
}

.topline__mark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f56aff;
  box-shadow: 0 0 10px rgba(245, 106, 255, 0.8);
}

.music {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 3;
}

.music .music__toggle {
  margin-left: auto;
  display: flex;
  font-size: 0.875rem;
  display: none;
}

.music__hint {
  position: absolute;
  right: 0;
  width: 190px;
  margin-top: 8px;
  color: #e9bbec;
  font-size: 0.8125rem;
  text-align: right;
  pointer-events: none;
}

.music__panel {
  width: min(330px, calc(100vw - 36px));
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid #f38aff30;
  border-radius: 18px;
  background: #100c16f5;
  box-shadow: 0 12px 45px #0008;
}

.music__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.875rem;
}

.music__heading strong { font-weight: 500; }
.music__heading span { display: block; color: #c9a6cf; margin-top: 4px; }
.music__heading button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #ffffff0d;
  color: #ffe5fa;
  font-size: 1.5rem;
  cursor: pointer;
}

.music__audio { display: block; width: 100%; height: 44px; }
.music__panel p { color: #d7c3dc; font-size: 0.875rem; line-height: 1.5; }
.music__panel :focus-visible { outline: 2px solid #fa7fff; outline-offset: 3px; }

.controls[hidden] {
  display: none;
}

.controls {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 54px;
  padding: 7px 8px 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(15, 14, 20, 0.66);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(18px) saturate(130%);
  transform: translateX(-50%);
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 114px;
  color: rgba(252, 244, 253, 0.67);
  font-size: 0.82rem;
  white-space: nowrap;
}

.status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f46dff;
  box-shadow: 0 0 12px rgba(244, 109, 255, 0.9);
  animation: status-breathe 1.8s ease-in-out infinite;
}

.controls__divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
}

button,
input {
  font: inherit;
}

.replay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: rgba(255, 249, 255, 0.86);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.replay:hover {
  color: #fff;
  border-color: rgba(248, 108, 255, 0.28);
  background: rgba(248, 108, 255, 0.1);
}

.replay:active {
  transform: scale(0.97);
}

.replay:focus-visible,
.loop-control:has(input:focus-visible) .switch {
  outline: 2px solid rgba(250, 127, 255, 0.86);
  outline-offset: 3px;
}

.replay svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loop-control {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 6px;
  color: rgba(252, 244, 253, 0.64);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.loop-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 35px;
  height: 21px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition:
    background 180ms ease,
    border-color 180ms ease;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition:
    transform 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.loop-control input:checked + .switch {
  border-color: rgba(244, 93, 255, 0.4);
  background: rgba(232, 69, 245, 0.28);
}

.loop-control input:checked + .switch span {
  background: #ffe9ff;
  box-shadow: 0 0 9px rgba(245, 102, 255, 0.7);
  transform: translateX(14px);
}

noscript {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}

.reactions {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(25px, env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
}

.reactions__button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid #ff83c84d;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #6e235c, #211125 75%);
  color: #ff91c5;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 0 22px #f762b51a, inset 0 1px 0 #ffffff1a;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.reactions__button:hover { box-shadow: 0 0 28px #f762b54d; }
.reactions__button:active { transform: scale(0.86); }
.reactions__button:focus-visible { outline: 2px solid #ffb5ef; outline-offset: 4px; }
.reactions__button span { filter: drop-shadow(0 0 5px #ff73be80); }
.reactions__count { margin-top: 7px; color: #f0c3e4; font-size: 0.875rem; font-variant-numeric: tabular-nums; opacity: 0}
.reactions__note { margin: 4px 0 0; color: #b697b1; font-size: 0.75rem; line-height: 1.4; text-align: center; display: none;}
.reactions__status {
  position: absolute;
  right: 95px;
  bottom: 30px;
  width: 180px;
  margin: 0;
  color: #ffccec;
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: right;
  pointer-events: none;
}
.reactions__stream {
  position: absolute;
  bottom: calc(100% - 25px);
  left: 50%;
  pointer-events: none;
}
.floating-heart {
  position: absolute;
  left: -16px;
  bottom: 0;
  color: var(--heart-color);
  font-size: var(--size);
  line-height: 1;
  text-shadow: 0 0 9px #fa69c84d;
  animation: heart-float var(--duration) ease-out both;
  will-change: transform, opacity;
}
@keyframes heart-float {
  0% { opacity: 0; transform: translate(0, 0) scale(0.55); }
  12% { opacity: 0.95; transform: translate(var(--sway), -25px) scale(1.12); }
  45% { opacity: 0.8; transform: translate(var(--drift), calc(var(--rise) * 0.48)) rotate(var(--tilt)) scale(1); }
  75% { opacity: 0.5; transform: translate(var(--sway), calc(var(--rise) * 0.78)) rotate(calc(var(--tilt) * -1)) scale(0.85); }
  100% { opacity: 0; transform: translate(var(--drift), var(--rise)) scale(0.65); }
}

@keyframes status-breathe {
  0%,
  100% {
    opacity: 0.48;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 560px) {
  .reactions { right: 9px; bottom: max(27px, calc(env(safe-area-inset-bottom) + 27px)); width: 76px; }
  .reactions__button { width: 50px; height: 50px; font-size: 20px; }
  .reactions__status { right: 77px; width: 170px; }
  .topline {
    top: max(18px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left));
  }

  .controls {
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
    gap: 10px;
    min-height: 50px;
    padding-left: 13px;
  }

  .status {
    min-width: 102px;
    font-size: 0.76rem;
  }

  .replay {
    min-height: 36px;
    padding: 0 11px;
    font-size: 0.78rem;
  }

  .loop-control {
    gap: 7px;
    font-size: 0.76rem;
  }
}

@media (max-width: 390px) {
  .controls {
    width: calc(100% - 28px);
    justify-content: space-between;
  }

  .controls__divider {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-heart { animation: heart-fade 550ms ease-out both; }
  .reactions__button { transition: none; }
  .status__dot {
    animation: none;
  }

  .replay,
  .switch,
  .switch span {
    transition-duration: 0.01ms;
  }
}

@keyframes heart-fade {
  from { opacity: 0.8; transform: translateY(-15px); }
  to { opacity: 0; transform: translateY(-15px); }
}
