:root {
  --bg: #0b0d12;
  --moon: #e8e0d0;
  --moon-dim: #b9b0a0;
  --amber: #c4a574;
  --amber-soft: rgba(196, 165, 116, 0.35);
  --ink: #12141a;
  --error: #e8a0a0;
  --howl-mark: clamp(46px, 11vw, 62px);
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--moon);
  font-family: Outfit, system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#map {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 0;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(11, 13, 18, 0.55) 100%),
    linear-gradient(to top, rgba(11, 13, 18, 0.72) 0%, transparent 28%);
}

.leaflet-container {
  background: var(--bg);
  font-family: Outfit, system-ui, sans-serif;
}

.leaflet-control-attribution {
  background: rgba(11, 13, 18, 0.55) !important;
  color: var(--moon-dim);
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: var(--amber);
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: none !important;
}

.leaflet-control-zoom a {
  background: rgba(18, 20, 26, 0.82) !important;
  color: var(--moon) !important;
  border: 1px solid rgba(232, 224, 208, 0.12) !important;
  width: 32px;
  height: 32px;
  line-height: 32px;
}

#hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 0 20px calc(var(--safe-bottom) + 12px);
  pointer-events: none;
}

#hud[hidden] {
  display: none;
}

#howl-btn {
  pointer-events: auto;
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #2a2e38 0%, #14171e 70%);
  color: var(--moon);
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(232, 224, 208, 0.16),
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 32px var(--amber-soft);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#howl-btn .howl-icon {
  position: relative;
  z-index: 1;
  width: 58px;
  height: 58px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

#howl-btn .howl-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 165, 116, 0.28), transparent 68%);
  opacity: 0.65;
  pointer-events: none;
}

#howl-btn.pressed {
  transform: scale(0.94);
  box-shadow:
    0 0 0 1px rgba(196, 165, 116, 0.55),
    0 8px 28px rgba(0, 0, 0, 0.5),
    0 0 48px rgba(196, 165, 116, 0.45);
}

#howl-btn.pressed .howl-glow {
  opacity: 1;
  animation: howl-press 1.1s ease-in-out infinite;
}

@keyframes howl-press {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 22%, rgba(196, 165, 116, 0.16), transparent 52%),
    rgba(11, 13, 18, 0.88);
  backdrop-filter: blur(8px);
}

.overlay[hidden] {
  display: none;
}

.fairies {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(92vw, 560px);
  height: 56%;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}

.fairies span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(248, 236, 210, 0.95);
  box-shadow:
    0 0 6px 2px rgba(232, 208, 160, 0.55),
    0 0 16px 6px rgba(196, 165, 116, 0.18);
  animation: fairy-drift 14s ease-in-out infinite;
  opacity: 0.45;
}

.fairies span:nth-child(1)  { left: 22%; top: 8%; width: 5px; height: 5px; animation-duration: 16s; animation-delay: -2s; }
.fairies span:nth-child(2)  { left: 72%; top: 6%; width: 3px; height: 3px; animation-duration: 18s; animation-delay: -7s; }
.fairies span:nth-child(3)  { left: 48%; top: 4%; width: 6px; height: 6px; animation-duration: 20s; animation-delay: -1s; opacity: 0.32; }
.fairies span:nth-child(4)  { left: 10%; top: 18%; width: 4px; height: 4px; animation-duration: 15s; animation-delay: -4s; }
.fairies span:nth-child(5)  { left: 88%; top: 16%; width: 3px; height: 3px; animation-duration: 17s; animation-delay: -11s; }
.fairies span:nth-child(6)  { left: 34%; top: 14%; width: 7px; height: 7px; animation-duration: 19s; animation-delay: -9s; opacity: 0.3; }
.fairies span:nth-child(7)  { left: 62%; top: 22%; width: 4px; height: 4px; animation-duration: 14s; animation-delay: -5s; }
.fairies span:nth-child(8)  { left: 16%; top: 36%; width: 5px; height: 5px; animation-duration: 16s; animation-delay: -13s; }
.fairies span:nth-child(9)  { left: 84%; top: 34%; width: 6px; height: 6px; animation-duration: 21s; animation-delay: -3s; }
.fairies span:nth-child(10) { left: 50%; top: 32%; width: 3px; height: 3px; animation-duration: 13s; animation-delay: -8s; }
.fairies span:nth-child(11) { left: 8%; top: 52%; width: 4px; height: 4px; animation-duration: 18s; animation-delay: -6s; }
.fairies span:nth-child(12) { left: 92%; top: 50%; width: 5px; height: 5px; animation-duration: 15s; animation-delay: -12s; }
.fairies span:nth-child(13) { left: 28%; top: 68%; width: 3px; height: 3px; animation-duration: 17s; animation-delay: -10s; }
.fairies span:nth-child(14) { left: 74%; top: 70%; width: 6px; height: 6px; animation-duration: 19s; animation-delay: -14s; }
.fairies span:nth-child(15) { left: 42%; top: 88%; width: 4px; height: 4px; animation-duration: 16s; animation-delay: -2.5s; }
.fairies span:nth-child(16) { left: 60%; top: 92%; width: 3px; height: 3px; animation-duration: 14s; animation-delay: -7.5s; }

@keyframes fairy-drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.22;
  }
  35% {
    transform: translate(6px, -8px) scale(1.12);
    opacity: 0.7;
  }
  70% {
    transform: translate(-5px, 6px) scale(0.92);
    opacity: 0.35;
  }
}

.gate-card {
  position: relative;
  width: min(100%, 380px);
  text-align: center;
  z-index: 1;
}

.brand {
  position: relative;
  margin: 0;
}

.mark {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin: 0 auto 12px;
  filter:
    drop-shadow(0 0 14px rgba(196, 165, 116, 0.35))
    drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

h1 {
  font-family: "Cinzel Decorative", Georgia, serif;
  font-weight: 400;
  font-size: var(--howl-mark);
  letter-spacing: 0.06em;
  line-height: 1;
  width: max-content;
  margin: 0 auto 44px;
  color: var(--moon);
  text-shadow:
    0 0 16px rgba(232, 224, 208, 0.28),
    0 0 36px rgba(196, 165, 116, 0.22);
  animation: title-glow 7s ease-in-out infinite;
}

@keyframes title-glow {
  0%,
  100% {
    text-shadow:
      0 0 14px rgba(232, 224, 208, 0.22),
      0 0 32px rgba(196, 165, 116, 0.16);
  }
  50% {
    text-shadow:
      0 0 22px rgba(248, 236, 210, 0.4),
      0 0 48px rgba(196, 165, 116, 0.32);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fairies span,
  h1,
  #join-btn {
    animation: none;
  }
}

#join-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#wolf-name {
  width: 50%;
  padding: 14px 16px;
  border: 1px solid rgba(232, 224, 208, 0.16);
  border-radius: 12px;
  background: rgba(18, 20, 26, 0.9);
  color: var(--moon);
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  outline: none;
}

#wolf-name::placeholder {
  color: var(--moon-dim);
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 400;
}

#wolf-name:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

#join-btn {
  width: auto;
  margin-top: 28px;
  padding: 13px 36px;
  border: 0;
  border-radius: 999px;
  background: var(--moon);
  color: var(--ink);
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  cursor: pointer;
  box-shadow:
    0 0 16px rgba(196, 165, 116, 0.32),
    0 0 36px rgba(232, 224, 208, 0.12);
  animation: join-glow 6s ease-in-out infinite;
}

#join-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  animation: none;
}

@keyframes join-glow {
  0%,
  100% {
    box-shadow:
      0 0 12px rgba(196, 165, 116, 0.22),
      0 0 28px rgba(232, 224, 208, 0.08);
  }
  50% {
    box-shadow:
      0 0 20px rgba(196, 165, 116, 0.42),
      0 0 44px rgba(232, 224, 208, 0.18);
  }
}

.error {
  color: var(--error);
  font-family: Outfit, system-ui, sans-serif;
  font-size: 13px;
  min-height: 1.2em;
  width: 100%;
  margin-top: 20px;
  text-align: center;
}

.hint {
  color: var(--moon-dim);
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.45;
  width: calc(var(--howl-mark) * 3.4);
  margin: 28px auto 0;
  text-align: center;
}

.wolf-icon {
  background: none !important;
  border: none !important;
}

.wolf-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 88px;
  transform: translateY(-8px);
}

.wolf-pulse {
  position: absolute;
  top: 6px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--wolf-tint, #fff), transparent 70%);
  box-shadow: 0 0 20px var(--wolf-tint, #fff);
  opacity: 0;
  pointer-events: none;
}

.wolf-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  box-shadow: inherit;
  opacity: 0;
}

.wolf-icon.howling .wolf-pulse {
  opacity: 1;
  animation: wolf-pulse 1.5s ease-out infinite;
}

.wolf-icon.howling .wolf-pulse::after {
  animation: wolf-pulse 1.5s ease-out infinite;
  animation-delay: 0.75s;
}

@keyframes wolf-pulse {
  0% {
    transform: scale(0.65);
    opacity: 0.95;
  }
  70% {
    transform: scale(2.35);
    opacity: 0;
  }
  100% {
    transform: scale(2.35);
    opacity: 0;
  }
}

.wolf-sprite {
  width: 52px;
  height: 52px;
  position: relative;
  z-index: 1;
  background-color: var(--wolf-tint, #fff);
  -webkit-mask-image: var(--wolf-src);
  mask-image: var(--wolf-src);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  user-select: none;
}

.wolf-icon.pose-listen .wolf-sprite {
  transform: scaleX(-1) scale(0.9);
  transform-origin: center center;
}

.wolf-icon.own .wolf-sprite {
  width: 58px;
  height: 58px;
  background-color: #fff;
  filter:
    drop-shadow(0 0 5px #fff)
    drop-shadow(0 0 12px #fff)
    drop-shadow(0 0 22px rgba(255, 255, 255, 1));
}

.wolf-name {
  margin-top: 2px;
  max-width: 88px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(11, 13, 18, 0.72);
  color: var(--moon);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

.wolf-icon.own .wolf-name {
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.85);
}
