:root {
    --violet-accent: #6f75d8;
    --violet-deep: #313868;
    --violet-paper: rgba(255, 255, 255, 0.94);
}

#violet-mascot {
    --shift-x: 0px;
    --tilt: 0deg;
    position: fixed;
    left: 18px;
    bottom: 0;
    z-index: 2147482000;
    width: clamp(220px, 21vw, 330px);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: opacity 180ms ease, visibility 180ms ease;
}

#violet-mascot.violet-mascot--route-hidden,
#violet-mascot.violet-mascot--user-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.violet-mascot__stage {
    position: relative;
    cursor: grab;
    transform-origin: 50% 100%;
    animation: violet-breathe 4.8s ease-in-out infinite;
    will-change: transform;
}

.violet-mascot__stage:active {
    cursor: grabbing;
}

.violet-mascot__image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 12px 18px rgba(25, 28, 56, 0.28));
}

.violet-mascot__bubble {
    position: absolute;
    top: 17%;
    left: 76%;
    width: min(260px, 48vw);
    padding: 12px 15px;
    border: 1px solid rgba(111, 117, 216, 0.25);
    border-radius: 14px 14px 4px 14px;
    background: var(--violet-paper);
    box-shadow: 0 10px 28px rgba(34, 38, 75, 0.16);
    color: var(--violet-deep);
    font-size: 14px;
    line-height: 1.65;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transform-origin: 100% 100%;
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

.violet-mascot__bubble::after {
    content: "";
    position: absolute;
    left: -8px;
    bottom: 14px;
    width: 16px;
    height: 16px;
    border-top: 1px solid rgba(111, 117, 216, 0.18);
    border-left: 1px solid rgba(111, 117, 216, 0.18);
    background: var(--violet-paper);
    transform: rotate(45deg);
}

#violet-mascot.violet-mascot--speaking .violet-mascot__bubble {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.violet-mascot__close {
    position: absolute;
    top: 6%;
    right: 5%;
    z-index: 2;
    display: grid;
    width: 28px;
    height: 28px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(111, 117, 216, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--violet-deep);
    cursor: pointer;
    opacity: 0;
    transition: opacity 160ms ease, transform 160ms ease;
}

#violet-mascot:hover .violet-mascot__close,
.violet-mascot__close:focus-visible {
    opacity: 1;
}

.violet-mascot__close:hover {
    transform: scale(1.08);
}

#violet-mascot-reopen {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 2147482000;
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(111, 117, 216, 0.42);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(34, 38, 75, 0.2);
    color: var(--violet-deep);
    font: 600 18px/1 Georgia, serif;
    cursor: pointer;
}

#violet-mascot-reopen.violet-mascot-reopen--visible {
    display: block;
}

@keyframes violet-breathe {
    0%, 100% {
        transform: translate3d(var(--shift-x), 0, 0) rotate(var(--tilt));
    }
    50% {
        transform: translate3d(var(--shift-x), -7px, 0) rotate(var(--tilt));
    }
}

@media (max-width: 720px) {
    #violet-mascot {
        left: 4px;
        width: clamp(170px, 42vw, 230px);
    }

    .violet-mascot__bubble {
        top: 4%;
        left: 64%;
        width: min(220px, 60vw);
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .violet-mascot__stage {
        animation: none;
    }

    #violet-mascot,
    .violet-mascot__bubble,
    .violet-mascot__close {
        transition: none;
    }
}
