html.spirit-chase-lock,
body.spirit-chase-lock {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.spirit-chase-modal {
  position: fixed;
  inset: 0;
  z-index: 12030;
  align-items: center;
  justify-content: center;
  --spirit-ui-text: #f6ead8;
  --spirit-ui-gold: #e8c88b;
  --spirit-ui-cyan: #69eaff;
  --spirit-ui-shadow: rgba(0, 0, 0, 0.62);
  --spirit-chase-world-bg: url('/static/images/worlds/hades/backgrounds/bg8.webp');
  --spirit-grid-aspect: 13 / 17;
  --spirit-grid-ratio: 0.7647;
  background: #040a0e;
  overflow: hidden;
  pointer-events: auto;
  overscroll-behavior: contain;
  touch-action: none;
}

.spirit-chase-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--spirit-chase-world-bg) center / cover no-repeat;
  filter: brightness(0.46) saturate(1.06);
  transform: scale(1.03);
  pointer-events: none;
}

.spirit-chase-modal::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 12%, rgba(105, 234, 255, 0.14), transparent 34%),
    radial-gradient(circle at 50% 88%, rgba(232, 200, 139, 0.12), transparent 40%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.spirit-chase-content {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: calc(var(--vh, 1vh) * 100);
  max-width: none;
  max-height: none;
  padding: clamp(22px, 4vh, 38px) clamp(14px, 5vw, 34px) max(14px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  background: transparent;
  color: var(--spirit-ui-text);
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
}

.spirit-chase-close {
  top: clamp(16px, 3vh, 30px);
  right: clamp(16px, 5vw, 32px);
  width: 38px;
  height: 38px;
}

.spirit-chase-title {
  max-width: calc(100% - 54px);
  min-height: 24px;
  margin: 0 0 3px;
  text-align: center;
  font-size: clamp(20px, 5vw, 25px);
  line-height: 1.15;
  text-shadow: 0 2px 5px #000, 0 0 14px rgba(105, 234, 255, 0.2);
}

.spirit-chase-hud {
  width: min(82vw, 330px);
  height: 42px;
  margin: 5px 0 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spirit-chase-target-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/static/images/icons/slot.webp') center / 100% 100% no-repeat;
  transition: filter 0.2s ease, opacity 0.2s ease;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.45));
}

.spirit-chase-target-mark img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
}

.spirit-chase-target-mark.caught {
  opacity: 0.32;
  filter: grayscale(1);
}

.spirit-chase-canvas {
  width: min(90vw, 340px);
  width: min(90vw, calc((var(--vh, 1vh) * 100 - 274px) * var(--spirit-grid-ratio)), 392px);
  height: auto;
  aspect-ratio: var(--spirit-grid-aspect);
  display: block;
  border: 2px solid rgba(224, 195, 151, 0.68);
  border-radius: 9px;
  background: #081317;
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.88),
    0 0 0 1px rgba(105, 234, 255, 0.13),
    0 14px 34px rgba(0, 0, 0, 0.56);
  touch-action: none;
}

.spirit-chase-dpad {
  position: relative;
  --dpad-visual-w: 62px;
  --dpad-visual-h: 55px;
  --dpad-hit-w: 92px;
  --dpad-hit-h: 78px;
  width: 244px;
  height: 150px;
  margin-top: clamp(6px, 1vh, 10px);
  margin-bottom: env(safe-area-inset-bottom, 0px);
  flex: 0 0 150px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.spirit-chase-dpad button {
  position: absolute;
  width: var(--dpad-hit-w);
  height: var(--dpad-hit-h);
  border: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/static/images/icons/button1.webp') center / var(--dpad-visual-w) var(--dpad-visual-h) no-repeat;
  color: var(--spirit-ui-text);
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 2px 4px #000;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  filter:
    drop-shadow(0 5px 0 rgba(0, 0, 0, 0.38))
    drop-shadow(0 0 10px rgba(105, 234, 255, 0.18));
  transition: filter 0.12s ease, transform 0.12s ease;
}

.spirit-chase-dpad button:active {
  filter:
    brightness(1.3)
    drop-shadow(0 2px 0 rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 13px rgba(105, 234, 255, 0.3));
  transform: translateY(3px) scale(0.96);
}

.spirit-chase-dpad [data-dir='up'] { top: 0; left: calc((100% - var(--dpad-hit-w)) / 2); }
.spirit-chase-dpad [data-dir='left'] { top: 72px; left: 0; }
.spirit-chase-dpad [data-dir='down'] { top: 72px; left: calc((100% - var(--dpad-hit-w)) / 2); }
.spirit-chase-dpad [data-dir='right'] { top: 72px; right: 0; }

.spirit-capture-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 22px);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.76);
  cursor: pointer;
  touch-action: none;
}

.spirit-capture-overlay.hidden {
  display: none;
}

.spirit-capture-card {
  width: min(94vw, 720px);
  height: min(calc(var(--vh, 1vh) * 82), 760px);
  max-height: none;
  padding: clamp(8px, 2vw, 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 2px solid rgba(232, 200, 139, 0.75);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 38%, rgba(105, 234, 255, 0.16), transparent 46%),
    rgba(5, 13, 17, 0.82);
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.62),
    0 18px 45px rgba(0, 0, 0, 0.65),
    0 0 24px rgba(105, 234, 255, 0.16);
  animation: spirit-capture-pop 0.2s ease-out;
}

.spirit-capture-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(91, 224, 255, 0.82));
  pointer-events: none;
}

@keyframes spirit-capture-pop {
  from { transform: scale(0.72); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
  .spirit-chase-content {
    padding: 30px 14px max(14px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  }

  .spirit-chase-close {
    top: 16px;
    right: 16px;
  }

  .spirit-chase-title {
    font-size: 21px;
  }

  .spirit-chase-canvas {
    width: min(91vw, 340px);
    width: min(91vw, calc((var(--vh, 1vh) * 100 - 266px) * var(--spirit-grid-ratio)), 392px);
  }

  .spirit-chase-dpad {
    margin-top: 8px;
  }
}

@media (max-height: 680px) {
  .spirit-chase-content {
    padding-top: 22px;
  }

  .spirit-chase-close {
    top: 13px;
  }

  .spirit-chase-hud {
    height: 36px;
    margin: 3px 0 5px;
  }

  .spirit-chase-target-mark {
    width: 31px;
    height: 31px;
  }

  .spirit-chase-canvas {
    width: min(90vw, 330px);
    width: min(90vw, calc((var(--vh, 1vh) * 100 - 250px) * var(--spirit-grid-ratio)), 392px);
  }

  .spirit-chase-dpad {
    --dpad-visual-w: 58px;
    --dpad-visual-h: 52px;
    --dpad-hit-w: 84px;
    --dpad-hit-h: 70px;
    width: 226px;
    height: 132px;
    flex-basis: 132px;
    margin-top: 6px;
  }

  .spirit-chase-dpad [data-dir='left'],
  .spirit-chase-dpad [data-dir='down'],
  .spirit-chase-dpad [data-dir='right'] {
    top: 62px;
  }
}
