:root {
  color-scheme: dark;
  --glass: rgba(9, 8, 8, 0.48);
  --glass-strong: rgba(9, 8, 8, 0.7);
  --line: rgba(255, 255, 255, 0.24);
  --text: #fff8ee;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080707;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  position: fixed;
  inset: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.viewer-shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 18% 12%, rgba(212, 174, 104, 0.16), transparent 34%),
    #080707;
  touch-action: none;
}

#viewer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
}

#viewer.is-dragging {
  cursor: grabbing;
}

.viewer-shell::before,
.viewer-shell::after {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  display: block;
  height: clamp(96px, 18vh, 180px);
  pointer-events: none;
  content: "";
}

.viewer-shell::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.58), transparent);
}

.viewer-shell::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.48), transparent);
}

.top-bar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  left: clamp(14px, 4vw, 36px);
  right: clamp(14px, 4vw, 36px);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand-mark {
  max-width: min(70vw, 440px);
  padding: 9px 13px;
  overflow: hidden;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 4vw, 28px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text);
  pointer-events: auto;
  cursor: pointer;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  background: var(--glass-strong);
  border-color: rgba(255, 255, 255, 0.44);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

.icon-button svg {
  position: absolute;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.music-on {
  opacity: 0;
}

.is-music-playing .music-on {
  opacity: 1;
}

.is-music-playing .music-off {
  opacity: 0;
}

.hint-card {
  position: absolute;
  right: clamp(16px, 4vw, 34px);
  bottom: calc(env(safe-area-inset-bottom) + clamp(18px, 4vh, 34px));
  z-index: 4;
  display: flex;
  align-items: center;
  max-width: min(84vw, 330px);
  min-height: 54px;
  padding: 10px 14px 10px 12px;
  gap: 11px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 320ms ease, transform 320ms ease;
}

.hint-card.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.hint-card p {
  margin: 0;
  font-size: clamp(12px, 3.2vw, 14px);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.drag-icon {
  position: relative;
  width: 42px;
  height: 30px;
  flex: 0 0 42px;
}

.drag-icon span {
  position: absolute;
  top: 12px;
  display: block;
  width: 13px;
  height: 3px;
  background: currentColor;
  border-radius: 999px;
  opacity: 0.88;
}

.drag-icon span:nth-child(1) {
  left: 1px;
  transform: rotate(35deg);
}

.drag-icon span:nth-child(2) {
  left: 14px;
}

.drag-icon span:nth-child(3) {
  right: 1px;
  transform: rotate(-35deg);
}

.drag-icon::before {
  position: absolute;
  inset: 3px 6px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  opacity: 0.8;
  content: "";
  animation: hint-scan 1.8s ease-in-out infinite;
}

.loader {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  place-items: center;
  gap: 14px;
  background: #080707;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.loader.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loader p {
  margin: 0;
  color: rgba(255, 248, 238, 0.8);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.loader-ring {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff7e6;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes hint-scan {
  0%,
  100% {
    transform: translateX(-7px);
  }

  50% {
    transform: translateX(7px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .top-bar {
    top: calc(env(safe-area-inset-top) + 12px);
    left: 12px;
    right: 12px;
  }

  .brand-mark {
    padding: 8px 12px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .hint-card {
    right: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 18px);
    transform: translateX(50%);
  }

  .hint-card.is-hidden {
    transform: translateX(50%) translateY(12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drag-icon::before,
  .loader-ring {
    animation: none;
  }
}
