:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02070a;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#artwork {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(12, 35, 45, 0.34), transparent 68%),
    #02070a;
  touch-action: none;
  cursor: crosshair;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  color: rgba(225, 245, 255, 0.84);
  background: #02070a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  transition: opacity 700ms ease, visibility 700ms ease;
}

#loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border: 1px solid rgba(188, 232, 255, 0.22);
  border-top-color: rgba(188, 232, 255, 0.92);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 3;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid rgba(220, 242, 255, 0.16);
  border-radius: 999px;
  color: rgba(234, 248, 255, 0.82);
  background: rgba(0, 8, 13, 0.38);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(8px, 1.8vw, 10px);
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  animation: hint-life 5.8s ease 1.1s both;
  pointer-events: none;
}

#modeButton {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(223, 245, 255, 0.16);
  border-radius: 50%;
  color: rgba(236, 249, 255, 0.82);
  background: rgba(0, 7, 11, 0.34);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  font: inherit;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

#modeButton:hover,
#modeButton:focus-visible {
  opacity: 1;
  transform: scale(1.06);
  outline: none;
  background: rgba(0, 7, 11, 0.56);
}

#modeButton:active {
  transform: scale(0.94);
}

#modeIcon {
  display: block;
  transform: translateY(-1px);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

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

@keyframes hint-life {
  0% { opacity: 0; transform: translate(-50%, 7px); }
  14%, 70% { opacity: 0.88; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

@media (pointer: coarse) {
  #artwork { cursor: default; }
  #modeButton { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .loader { animation-duration: 1800ms; }
  #hint { animation: none; opacity: 0.72; }
}
