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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    "Segoe UI", Roboto, sans-serif;
  color: #fff;
  background: #ffd1e8;
}

body {
  background: radial-gradient(circle at 20% 20%, #ffe6f2 0%, transparent 60%),
    radial-gradient(circle at 80% 30%, #e8d4ff 0%, transparent 55%),
    radial-gradient(circle at 50% 90%, #d4f1ff 0%, transparent 60%),
    linear-gradient(180deg, #ffd1e8 0%, #e0c8ff 50%, #cce8ff 100%);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* ---------- Loading ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at center, #ffd1e8 0%, #b39bff 100%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

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

.spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}

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

.loader-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.dots span {
  display: inline-block;
  animation: blink 1.2s infinite both;
}
.dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%, 80%, 100% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
}

.loader-bar {
  width: min(280px, 70vw);
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6bb5, #ffd93d, #6bcfff, #95e1a3);
  background-size: 300% 100%;
  animation: shimmer 2s linear infinite;
  border-radius: 999px;
  transition: width 0.2s ease;
}

@keyframes shimmer {
  to {
    background-position: 300% 0;
  }
}

.loader-pct {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.8;
}

/* ---------- Brand / Hint ---------- */
.brand {
  position: fixed;
  top: 18px;
  left: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ff3c8e;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  box-shadow: 0 6px 20px rgba(255, 60, 140, 0.18);
  user-select: none;
}

.brand .paw {
  font-size: 1.1rem;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #7a2b8a;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 6px 20px rgba(122, 43, 138, 0.15);
  max-width: calc(100vw - 24px);
  user-select: none;
}

.hint-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.hint-item .icon {
  font-size: 0.95rem;
}

.spin-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6bb5, #b39bff);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 10px rgba(255, 107, 181, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.spin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(255, 107, 181, 0.5);
}

.spin-btn:active {
  transform: translateY(0);
}

.spin-btn[aria-pressed="false"] {
  filter: grayscale(0.4) brightness(0.95);
}

/* ---------- Theme picker ---------- */
.themes {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(80, 30, 120, 0.15);
  max-width: calc(100vw - 28px);
  justify-content: flex-end;
}

.theme-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  color: #6a2b8a;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
  white-space: nowrap;
}

.theme-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.85);
}

.theme-btn.is-active {
  background: linear-gradient(135deg, #ff6bb5, #b39bff);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 107, 181, 0.4);
}

.theme-btn span {
  display: inline-block;
}

@media (max-width: 640px) {
  .themes {
    top: 58px;
    right: 10px;
    left: 10px;
    max-width: none;
    padding: 5px;
    justify-content: center;
  }
  .theme-btn {
    font-size: 0.72rem;
    padding: 6px 9px;
    gap: 3px;
  }
  .theme-btn span {
    display: none;
  }
  .theme-btn.is-active span {
    display: inline-block;
  }
}

@media (max-width: 520px) {
  .brand {
    top: 12px;
    left: 12px;
    font-size: 0.85rem;
    padding: 6px 12px;
  }
  .hint {
    font-size: 0.75rem;
    gap: 6px;
    padding: 8px 10px;
  }
  .hint-item .icon {
    font-size: 0.85rem;
  }
  .spin-btn {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
}
