.mod-halloween {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.mod-halloween__creature {
    position: fixed;
    display: block;
    width: var(--hw-size);
    height: var(--hw-size);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    object-fit: contain;
    object-position: center;
    opacity: var(--hw-opacity);
    transform: translate(-50%, -50%) rotate(var(--hw-rotate, 0deg));
    transform-origin: center center;
    will-change: transform, opacity, left, top;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    animation-timing-function: ease-in-out;
}

.mod-halloween--clickable .mod-halloween__creature {
    pointer-events: auto;
    cursor: pointer;
}

.mod-halloween__creature:not(.hw-special) {
    left: var(--hw-left);
    top: var(--hw-top);
    animation-name: hw-still;
    animation-duration: var(--hw-duration);
    animation-iteration-count: infinite;
}

.mod-halloween__creature.hw-float { animation-name: hw-float; }
.mod-halloween__creature.hw-sway { animation-name: hw-sway; }
.mod-halloween__creature.hw-pulse { animation-name: hw-pulse; }

.mod-halloween__creature.hw-special {
    left: 0;
    top: 0;
    animation-duration: var(--hw-special-duration);
    animation-iteration-count: 1;
    animation-fill-mode: both;
}

@keyframes hw-still {
    0%, 100% { transform: translate(-50%, -50%) rotate(var(--hw-rotate, 0deg)); }
}

@keyframes hw-float {
    0%, 100% { transform: translate(-50%, calc(-50% - var(--hw-move))) rotate(var(--hw-rotate, 0deg)); }
    50% { transform: translate(-50%, calc(-50% + var(--hw-move))) rotate(var(--hw-rotate, 0deg)); }
}

@keyframes hw-sway {
    0%, 100% { transform: translate(calc(-50% - var(--hw-move)), -50%) rotate(calc(var(--hw-rotate, 0deg) - 2deg)); }
    50% { transform: translate(calc(-50% + var(--hw-move)), -50%) rotate(calc(var(--hw-rotate, 0deg) + 2deg)); }
}

@keyframes hw-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(var(--hw-rotate, 0deg)); }
    50% { transform: translate(-50%, -50%) scale(1.06) rotate(var(--hw-rotate, 0deg)); }
}

/* Dedicated paths for the four special creatures. */
@keyframes hw-path-spider {
    0% { left: var(--hw-start-x); top: var(--hw-start-y); transform: translate(-50%, -50%) rotate(0deg); }
    100% { left: var(--hw-end-x); top: var(--hw-end-y); transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes hw-path-ghost {
    0% { left: var(--hw-start-x); top: var(--hw-start-y); transform: translate(-50%, -50%) scaleX(1); }
    50% { left: var(--hw-end-x); top: var(--hw-end-y); transform: translate(-50%, -50%) scaleX(1); }
    100% { left: var(--hw-start-x); top: var(--hw-start-y); transform: translate(-50%, -50%) scaleX(1); }
}

@keyframes hw-path-raven {
    0% { left: var(--hw-start-x); top: var(--hw-start-y); transform: translate(-50%, -50%) rotate(var(--hw-rotate, 0deg)); }
    100% { left: var(--hw-end-x); top: var(--hw-end-y); transform: translate(-50%, -50%) rotate(var(--hw-rotate, 0deg)); }
}

@keyframes hw-path-bat {
    0% { left: var(--hw-start-x); top: var(--hw-start-y); transform: translate(-50%, -50%); }
    100% { left: var(--hw-end-x); top: var(--hw-end-y); transform: translate(-50%, -50%); }
}

@media (prefers-reduced-motion: reduce) {
    .mod-halloween__creature { animation: none !important; }
}

@media (max-width: 700px) {
    .mod-halloween__creature {
        width: min(var(--hw-size), 22vw);
        height: min(var(--hw-size), 22vw);
    }
}

/* Visitor-facing collapsible settings panel. The panel lives inside the
   full-screen module layer but receives pointer events independently. */
.mod-halloween__controls {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: min(330px, calc(100vw - 36px));
    box-sizing: border-box;
    pointer-events: auto;
    z-index: calc(var(--hw-z-index, 99990) + 1);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.35;
}

.mod-halloween__control-toggle,
.mod-halloween__settings button {
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 8px;
    background: rgba(20, 12, 24, .92);
    color: #fff;
    box-shadow: 0 5px 22px rgba(0,0,0,.32);
    cursor: pointer;
    font: inherit;
}

.mod-halloween__control-toggle {
    display: block;
    margin-left: auto;
    padding: 9px 13px;
}

.mod-halloween__control-toggle:hover,
.mod-halloween__settings button:hover {
    background: rgba(45, 24, 52, .96);
}

.mod-halloween__control-toggle:focus-visible,
.mod-halloween__settings button:focus-visible,
.mod-halloween__settings input:focus-visible,
.mod-halloween__settings select:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.mod-halloween__settings {
    box-sizing: border-box;
    margin-bottom: 8px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    background: rgba(16, 10, 20, .94);
    color: #fff;
    box-shadow: 0 8px 30px rgba(0,0,0,.4);
    backdrop-filter: blur(6px);
}

.mod-halloween__settings-title {
    margin: 0 0 10px;
    font-weight: 700;
    font-size: 16px;
}

.mod-halloween__setting {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    margin: 8px 0;
    align-items: center;
}

.mod-halloween__setting-label {
    min-width: 0;
}

.mod-halloween__setting input[type="range"] {
    grid-column: 1 / 2;
    width: 100%;
    margin: 0;
}

.mod-halloween__setting output {
    grid-column: 2 / 3;
    min-width: 42px;
    text-align: right;
    opacity: .9;
    font-variant-numeric: tabular-nums;
}

.mod-halloween__setting select {
    grid-column: 1 / 3;
    width: 100%;
    min-height: 32px;
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 6px;
    background: rgba(0,0,0,.4);
    color: #fff;
    padding: 5px 7px;
    font: inherit;
}

.mod-halloween__settings-note {
    margin-top: 9px;
    font-size: 12px;
    opacity: .72;
}

.mod-halloween__settings-actions {
    display: flex;
    gap: 7px;
    margin-top: 11px;
}

.mod-halloween__settings-actions button {
    padding: 7px 9px;
    font-size: 12px;
}

.mod-halloween__reset {
    flex: 1;
}

.mod-halloween__close {
    flex: 0 0 auto;
}

@media (max-width: 700px) {
    .mod-halloween__controls {
        right: 10px;
        bottom: 10px;
        width: min(320px, calc(100vw - 20px));
    }
}

/* Visitor panel themes. The template option intentionally removes the
   module's visual skin so the active Joomla template can style the controls. */
.mod-halloween__controls.hw-theme-template .mod-halloween__control-toggle,
.mod-halloween__controls.hw-theme-template .mod-halloween__settings,
.mod-halloween__controls.hw-theme-template .mod-halloween__settings button,
.mod-halloween__controls.hw-theme-template .mod-halloween__settings select {
    background: inherit;
    color: inherit;
    border-color: currentColor;
    box-shadow: none;
    backdrop-filter: none;
}

.mod-halloween__controls.hw-theme-template .mod-halloween__control-toggle,
.mod-halloween__controls.hw-theme-template .mod-halloween__settings button {
    font: inherit;
}

.mod-halloween__controls.hw-theme-dark {
    color: #ffffff;
}

.mod-halloween__controls.hw-theme-dark .mod-halloween__control-toggle,
.mod-halloween__controls.hw-theme-dark .mod-halloween__settings,
.mod-halloween__controls.hw-theme-dark .mod-halloween__settings button,
.mod-halloween__controls.hw-theme-dark .mod-halloween__settings select {
    background: #171717;
    color: #ffffff;
    border-color: #ffffff;
}

.mod-halloween__controls.hw-theme-dark .mod-halloween__control-toggle:hover,
.mod-halloween__controls.hw-theme-dark .mod-halloween__settings button:hover {
    background: #303030;
}

.mod-halloween__controls.hw-theme-dark .mod-halloween__settings input[type="range"] {
    accent-color: #ffffff;
}

.mod-halloween__controls.hw-theme-light {
    color: #111111;
}

.mod-halloween__controls.hw-theme-light .mod-halloween__control-toggle,
.mod-halloween__controls.hw-theme-light .mod-halloween__settings,
.mod-halloween__controls.hw-theme-light .mod-halloween__settings button,
.mod-halloween__controls.hw-theme-light .mod-halloween__settings select {
    background: #ffffff;
    color: #111111;
    border-color: #111111;
}

.mod-halloween__controls.hw-theme-light .mod-halloween__control-toggle:hover,
.mod-halloween__controls.hw-theme-light .mod-halloween__settings button:hover {
    background: #eeeeee;
}

.mod-halloween__controls.hw-theme-light .mod-halloween__settings input[type="range"] {
    accent-color: #111111;
}
