﻿.disguise-mask {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(216, 178, 94, 0.55);
    border-radius: 50%;
    background: rgba(12, 10, 7, 0.72);
    color: #d8b25e;
    cursor: pointer;
    opacity: 0;
    z-index: 20;
    transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.chess4-square:hover .disguise-mask,
.chess-square:hover .disguise-mask {
    opacity: 1;
    pointer-events: auto;
}

.disguise-mask__icon {
    width: 28px;
    height: 28px;
    display: block;
    transform: translateX(4px) translateY(2px);
    pointer-events: none;
}

.disguise-mask:hover {
    color: #f1cf7b;
    border-color: rgba(241, 207, 123, 0.9);
    background: rgba(25, 19, 10, 0.92);
    box-shadow: 0 0 9px rgba(216, 178, 94, 0.38);
    transform: scale(1.08);
}

.disguise-mask:active {
    transform: scale(0.96);
}

.disguise-mask:focus-visible {
    outline: 2px solid #f1cf7b;
    outline-offset: 2px;
}

/* Wrapper that holds both layers, co-located in the square.
   Only used when a disguise is present. */
.piece-disguise-stack {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

    /* Both layers fill the same box (co-centered); the slight offsets +
   depth treatment below distinguish them. */
    .piece-disguise-stack .disguise-layer-true,
    .piece-disguise-stack .disguise-layer-mask {
        position: absolute;
        inset: 0;
    }

    /* TRUE piece = the substrate ("the body underneath").
   Full-ish presence so the owner never loses the real identity,
   but recessed: dimmed, slightly smaller, nudged back/left, blurred a touch
   so it reads as behind. */
    .piece-disguise-stack .disguise-layer-mask {
        z-index: 10;
        opacity: 0.65;
        filter: saturate(0.65) brightness(0.8) blur(0.4px);
        transform: translate(-9%, -4%) scale(0.9);
        transform-origin: center;
    }

    /* DISGUISE = the worn costume ("what they see"), in front.
   Sharp, rim-lit glow so it reads as an intentional overlay/costume,
   nudged front/right the opposite direction to reveal both silhouettes. */
    .piece-disguise-stack .disguise-layer-true {
        z-index: 20;
        opacity: 1.0;
        transform: translate(7%, 7%) scale(0.6);
        transform-origin: center;
        /* rim glow — this is what sells "worn layer" vs "second piece" */
        filter: drop-shadow(0 0 2px var(--disguise-glow, #d8b25e)) drop-shadow(0 0 5px var(--disguise-glow, #d8b25e));
    }

    /* 3D theme: the true piece already applies the stand  upright transform via
   .chess-piece-threed; the offset/scale here compose ON TOP, so keep the
   disguise offsets smaller in 3D to avoid drift off the tile. */
    .piece-disguise-stack.threed .disguise-layer-mask {
        transform: rotateX(-22deg) translateY(-6px) translateX(5px) scaleY(calc(var(--piece-scale-y, 1) * 0.9)) scaleX(calc(var(--piece-scale-x, 1) * 0.9));
    }

    .piece-disguise-stack.threed .disguise-layer-true {
        /*transform: translate(6%, -3%) scale(0.6);*/
        transform: rotateX(-22deg) translateY(12px) translateX(16px) scaleY(calc(var(--piece-scale-y, 1) * 0.65)) scaleX(calc(var(--piece-scale-x, 1) * 0.65));
    }

/*
    Disguise selector modal
*/
.disguise-selector-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.61);
    backdrop-filter: blur(3px);
    z-index: 2000;
}

.disguise-selector {
    width: min(460px, calc(100vw - 2rem));
    padding: 1.2rem;
    border: 1px solid rgba(216, 178, 94, 0.55);
    border-radius: 12px;
    background: radial-gradient( circle at 50% 0%, rgba(216, 178, 94, 0.10), transparent 45% ), rgba(8, 7, 6, 0.97);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7), 0 0 20px rgba(216, 178, 94, 0.12);
    color: #ead8ab;
}

.disguise-selector__header {
    text-align: center;
    margin-bottom: 1rem;
}

.disguise-selector__title {
    color: #d8b25e;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.disguise-selector__subtitle {
    margin-top: 0.25rem;
    color: rgba(234, 216, 171, 0.62);
    font-size: 0.78rem;
}

.disguise-selector__pieces {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
}

.disguise-selector__piece {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.25rem;
    border: 1px solid rgba(216, 178, 94, 0.20);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
    color: rgba(234, 216, 171, 0.78);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

    .disguise-selector__piece img {
        width: 54px;
        height: 54px;
        object-fit: contain;
        pointer-events: none;
    }

    .disguise-selector__piece span {
        font-size: 0.7rem;
        font-weight: 600;
    }

    .disguise-selector__piece:hover {
        border-color: rgba(216, 178, 94, 0.8);
        background: rgba(216, 178, 94, 0.08);
        box-shadow: 0 0 12px rgba(216, 178, 94, 0.12);
        transform: translateY(-2px);
    }

    .disguise-selector__piece:active {
        transform: translateY(0) scale(0.97);
    }

    .disguise-selector__piece:focus-visible {
        outline: 2px solid #d8b25e;
        outline-offset: 2px;
    }

.disguise-selector__cancel {
    width: 100%;
    margin-top: 1rem;
    padding: 0.65rem 1rem;
    border: 1px solid rgba(216, 178, 94, 0.22);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.025);
    color: rgba(234, 216, 171, 0.68);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

    .disguise-selector__cancel:hover {
        border-color: rgba(216, 178, 94, 0.55);
        background: rgba(216, 178, 94, 0.06);
        color: #ead8ab;
    }

@media (max-width: 500px) {
    .disguise-selector {
        padding: 1rem;
    }

    .disguise-selector__pieces {
        grid-template-columns: repeat(3, 1fr);
    }

    .disguise-selector__piece {
        min-height: 82px;
    }

        .disguise-selector__piece img {
            width: 48px;
            height: 48px;
        }
}

.player-card__disguise-tools {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.player-card__disguises-used {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    padding: .15rem .3rem;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 10px;
}

    .player-card__disguises-used .disguise-mask__icon {
        width: 26px;
        height: 26px;
        flex: 0 0 auto;
    }

    .player-card__disguises-used span {
        line-height: 1;
    }

    .player-card__disguises-used:hover {
        background: rgba(216, 178, 94, .10);
    }

.player-card__feature-help {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(216, 178, 94, .35);
    border-radius: 50%;
    background: transparent;
    color: rgba(216, 178, 94, .7);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

    .player-card__feature-help:hover {
        color: #f1cf7b;
        border-color: #d8b25e;
        background: rgba(216, 178, 94, .10);
    }

.disguise-count--available {
    color: #8fcf8f;
}

.disguise-count--active {
    color: #d8b25e;
}

.disguise-count--full {
    color: #d96a58;
    font-weight: 700;
}

.disguise-count__max {
    color: rgba(235, 229, 214, 0.55);
}

.disguise--partially-betrayed .disguise-layer-mask {
    transform: translateY(12%) scale(0.98);
    opacity: 0.8;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 22%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 22%);
}

.disguise--flicker {
    animation: disguise-betrayal-flicker 2.4s 1;
    will-change: opacity, filter, transform;
}

@keyframes disguise-betrayal-flicker {
    0%, 7%, 12%, 31%, 36%, 58%, 63%, 82%, 100% {
        opacity: 1;
        filter: brightness(1);
        transform: translateX(0);
    }

    8% {
        opacity: 0.45;
        filter: brightness(1.35);
        transform: translateX(-1px);
    }

    9% {
        opacity: 0.8;
        filter: brightness(0.8);
        transform: translateX(1px);
    }

    32% {
        opacity: 0.25;
        filter: brightness(1.5);
        transform: translateX(1px);
    }

    33%, 34% {
        opacity: 0.7;
        filter: brightness(0.85);
        transform: translateX(-1px);
    }

    59% {
        opacity: 0.4;
        filter: brightness(1.4);
        transform: translateX(-1px);
    }

    60% {
        opacity: 0.9;
        filter: brightness(0.9);
        transform: translateX(1px);
    }

    83% {
        opacity: 0.3;
        filter: brightness(1.45);
        transform: translateX(0);
    }
}