/* K3pesh Board CSS */

#game-area {
    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    position: relative;
}

#top-bar {
    width: 90%;

    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-bottom: 16px;
}

.timer {
    width: 180px;

    text-align: center;

    padding: 12px;

    background: rgba(0, 0, 0, 0.45);

    border:
        1px solid rgba(255, 255, 255, 0.14);

    font-size: 1.3rem;

    color: var(--white);

    box-shadow:
        0 0 12px rgba(255, 255, 255, 0.08);
}

#status-display {
    font-size: 1rem;

    color: var(--red);

    letter-spacing: 3px;

    text-transform: uppercase;
}

#combat-announcer {
    max-width: 280px;

    font-size: 0.82rem;
    color: var(--muted);

    text-align: center;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#board-container {
    width: min(84vmin, 920px);
    height: min(84vmin, 920px);

    display: flex;
    justify-content: center;
    align-items: center;
}

#k3pesh-board {
    width: 100%;
    height: 100%;

    background-image: url(../assets/k3pesh_bg.png);

    position: relative;

    overflow: hidden;

    border:
        2px solid rgba(255, 255, 255, 0.16);

    box-shadow:
        0 0 30px rgba(255, 63, 79, 0.15);
}

.hex {
    position: absolute;

    width: var(--hex-width);
    height: var(--hex-height);

    clip-path:
        polygon(
            25% 0%,
            75% 0%,
            100% 50%,
            75% 100%,
            25% 100%,
            0% 50%
        );

    display: flex;
    justify-content: center;
    align-items: center;

    border:
        1px solid rgba(255, 255, 255, 0.18);

    cursor: pointer;

    transition:
        filter 0.15s ease,
        box-shadow 0.15s ease;
}

.hex.home-zone {
    background: rgba(122, 184, 255, 0.08);
}

.hex.neutral-zone {
    background: rgba(255, 255, 255, 0.06);
}

.hex.danger-zone {
    background: rgba(255, 63, 79, 0.08);
}

.hex:hover {
    filter: brightness(1.55);
}

.hex.selected {
    box-shadow:
        inset 0 0 20px rgba(255, 255, 255, 0.55),
        0 0 18px rgba(255, 255, 255, 0.45);

    z-index: 5;
}

.hex.legal-move {
    box-shadow:
        inset 0 0 18px rgba(122, 184, 255, 0.65),
        0 0 14px rgba(122, 184, 255, 0.55);

    z-index: 4;
}

.hex.legal-attack {
    box-shadow:
        inset 0 0 20px rgba(255, 63, 79, 0.8),
        0 0 16px rgba(255, 63, 79, 0.75);

    z-index: 4;
}

.unit {
    position: absolute;

    width: var(--hex-width);
    height: var(--hex-height);

    display: flex;
    justify-content: center;
    align-items: center;

    pointer-events: none;

    z-index: 20;

    transform: translate(-50%, -50%);
}

.unit-sprite {
    object-fit: contain;

    filter:
        drop-shadow(
            0 0 8px rgba(255, 255, 255, 0.28)
        );
}

.unit-type-fighter {
    width: 50%;
    height: 50%;
}

.unit-type-frigate {
    width: 70%;
    height: 70%;
}

.unit-type-dreadnought {
    width: 90%;
    height: 90%;
}

.unit-type-stealthFrigate {
    width: 75%;
    height: 75%;
}

.unit-type-homeworld {
    width: 95%;
    height: 95%;
}

.unit-type-cruiser {
    width: 80%;
    height: 80%;
}

.unit-type-battlecruiser {
    width: 90%;
    height: 90%;

    filter:
        drop-shadow(0 0 10px rgba(255, 80, 80, 0.85))
        drop-shadow(0 0 20px rgba(0, 245, 255, 0.35));
}

.battlecruiser-unit .unit-sprite {
    filter:
        drop-shadow(0 0 10px rgba(255, 80, 80, 0.9))
        drop-shadow(0 0 20px rgba(0, 245, 255, 0.45));
}

.unit-type-carrier {
    width: 95%;
    height: 95%;
    filter:
        drop-shadow(0 0 10px rgba(0,245,255,.7))
        drop-shadow(0 0 18px rgba(255,255,255,.35));
}

.unit-type-harvester {
    width: 105%;
    height: 105%;
}

.carrier-spawn-flash .unit-sprite {
    animation:
        carrierSpawnFlash 0.85s ease;
}

.carrier-destruction-flash .unit-sprite {
    animation:
        carrierDestructionFlash 0.75s ease;
}

.fighter-spawn-flash .unit-sprite {
    animation:
        fighterSpawnFlash 0.55s ease;
}

.ftl-despawn-flash .unit-sprite {
    animation:
        ftlDespawnFlash 0.8s ease forwards;
}

.ftl-despawn-flash .unit-hp-bar {
    animation:
        ftlHpBarDespawn
        0.35s
        ease
        forwards;
}

.ftl-despawn-complete .unit-sprite {
    opacity: 0;
}

.ftl-despawn-complete .unit-hp-bar {
    opacity: 0;
    visibility: hidden;
}

@keyframes ftlHpBarDespawn {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes carrierSpawnFlash {
    0% {
        opacity: 0;
        transform: rotate(var(--unit-rotation)) scale(0.4);
        filter:
            drop-shadow(0 0 18px rgba(0, 245, 255, 1))
            drop-shadow(0 0 34px rgba(255, 255, 255, 0.75));
    }

    45% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1.18);
        filter:
            drop-shadow(0 0 22px rgba(0, 245, 255, 0.95))
            drop-shadow(0 0 38px rgba(255, 60, 60, 0.45));
    }

    100% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1);
        filter:
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.28));
    }
}

@keyframes fighterSpawnFlash {
    0% {
        opacity: 0;
        transform: rotate(var(--unit-rotation)) scale(0.35);
        filter:
            drop-shadow(0 0 16px rgba(0, 245, 255, 1));
    }

    60% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1.28);
        filter:
            drop-shadow(0 0 20px rgba(0, 245, 255, 0.9))
            drop-shadow(0 0 30px rgba(255, 255, 255, 0.55));
    }

    100% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1);
    }
}

@keyframes ftlDespawnFlash {
    0% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1);
        filter:
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.28));
    }

    40% {
        opacity: 1;
        transform: rotate(var(--unit-rotation)) scale(1.25);
        filter:
            drop-shadow(0 0 24px rgba(0, 245, 255, 1))
            drop-shadow(0 0 40px rgba(255, 255, 255, 0.85));
    }

    100% {
        opacity: 0;
        transform:
            rotate(var(--unit-rotation))
            scale(0.15)
            translateY(-18px);
        filter:
            drop-shadow(0 0 34px rgba(0, 245, 255, 0.9));
    }
}

@keyframes carrierDestructionFlash {
    0% {
        transform: rotate(var(--unit-rotation)) scale(1);
        opacity: 1;
        filter:
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.28));
    }

    35% {
        transform: rotate(var(--unit-rotation)) scale(1.25);
        opacity: 1;
        filter:
            drop-shadow(0 0 22px rgba(255, 50, 50, 1))
            drop-shadow(0 0 38px rgba(255, 160, 40, 0.9));
    }

    100% {
        transform: rotate(var(--unit-rotation)) scale(0.4);
        opacity: 0;
        filter:
            drop-shadow(0 0 40px rgba(255, 0, 0, 0.95));
    }
}

.camouflaged-friendly .unit-sprite {
    opacity: 0.35;

    filter:
        drop-shadow(0 0 10px rgba(80, 220, 255, 0.95))
        drop-shadow(0 0 22px rgba(120, 80, 255, 0.65));
}

.camouflaged-hidden {
    opacity: 0;
}

.camouflaged-hidden .unit-hp-bar {
    display: none;
}

.camouflage-flash .unit-sprite {
    animation:
        camouflageFlash 0.7s ease;
}

.camouflage-reveal-flash .unit-sprite {
    animation:
        camouflageRevealFlash 0.7s ease;
}

@keyframes camouflageFlash {
    0% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1);
        filter:
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.28));
    }

    60% {
        opacity: 0.55;
        transform:
            rotate(var(--unit-rotation))
            scale(1.15);
        filter:
            drop-shadow(0 0 18px rgba(80, 220, 255, 1))
            drop-shadow(0 0 32px rgba(120, 80, 255, 0.85));
    }

    100% {
        opacity: 0.35;
        transform:
            rotate(var(--unit-rotation))
            scale(1);
    }
}

@keyframes camouflageRevealFlash {
    0% {
        opacity: 0.2;
        transform:
            rotate(var(--unit-rotation))
            scale(0.9);
        filter:
            drop-shadow(0 0 22px rgba(80, 220, 255, 1));
    }

    55% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1.18);
        filter:
            drop-shadow(0 0 24px rgba(255, 255, 255, 0.95))
            drop-shadow(0 0 36px rgba(80, 220, 255, 0.9));
    }

    100% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1);
    }
}

.unit-sprite {
    --unit-rotation: 0deg;
    transform: rotate(var(--unit-rotation));
}

.enemy-facing {
    --unit-rotation: 180deg;
}

.unit-token {
    width: 100%;
    height: 100%;

    border-radius: 50%;

    display: flex;
    justify-content: center;
    align-items: center;

    font-size: 0.7rem;
    font-weight: bold;

    border:
        1px solid rgba(255, 255, 255, 0.35);

    background: rgba(12, 16, 22, 0.9);
}

.unit.alliance .unit-token {
    color: #b7d8ff;

    box-shadow:
        0 0 12px rgba(122, 184, 255, 0.35);
}

.unit.pirates .unit-token {
    color: #ff8b92;

    box-shadow:
        0 0 12px rgba(255, 63, 79, 0.35);
}

.unit-hp-bar {
    position: absolute;

    top: 2.5%;
    left: 14%;

    width: 72%;
    height: 4px;

    overflow: hidden;

    background: rgba(0, 0, 0, 0.75);

    border:
        1px solid rgba(255, 255, 255, 0.18);
}

.unit-hp-fill {
    position: absolute;

    left: 0;
    top: 0;

    height: 100%;

    background: #00ff75;

    transition:
        width 0.2s ease;
}

.unit-shield-fill {
    position: absolute;

    top: 0;

    height: 100%;

    display: none;

    background: #26d9ff;

    box-shadow:
        0 0 6px rgba(38, 217, 255, 0.95);

    transition:
        left 0.2s ease,
        width 0.2s ease;
}

.unit-token {
    display: none;
}

.unit-token.fallback-visible {
    display: flex;
}

.hidden-sprite {
    display: none;
}

.unit-animation-ghost {
    position: absolute;

    width: var(--hex-width);
    height: var(--hex-height);

    display: flex;
    justify-content: center;
    align-items: center;

    pointer-events: none;

    z-index: 50;

    transform: translate(-50%, -50%);
}

.unit-animation-ghost .unit-hp-bar {
    display: none;
}

.unit-animation-ghost .unit-sprite {
    width: 72%;
    height: 72%;
}

.unit-animation-ghost .unit-token {
    width: 72%;
    height: 72%;
}

.hex-field {
    position: absolute;

    left: 50%;
    top: 50%;

    transform: translate(-50%, -50%);

    width: 98%;
    height: 98%;

    overflow: visible;
}

.hex-layer,
.unit-layer {
    position: absolute;

    inset: 0;

    overflow: visible;
}

.hex-layer {
    z-index: 1;
}

.unit-layer {
    z-index: 10;

    pointer-events: none;
}

.homeworld-state-flash {
    animation:
        homeworldStateFlash 0.55s ease;
}

@keyframes homeworldStateFlash {
    0% {
        transform:
            rotate(var(--unit-rotation))
            scale(1)
            translateX(0);
        filter:
            drop-shadow(0 0 0 rgba(255, 255, 255, 0));
    }

    25% {
        transform:
            rotate(var(--unit-rotation))
            scale(1.12)
            translateX(-2px);
        filter:
            drop-shadow(0 0 16px rgba(0, 245, 255, 0.95))
            drop-shadow(0 0 26px rgba(255, 60, 60, 0.55));
    }

    50% {
        transform:
            rotate(var(--unit-rotation))
            scale(1.08)
            translateX(2px);
    }

    75% {
        transform:
            rotate(var(--unit-rotation))
            scale(1.05)
            translateX(-1px);
    }

    100% {
        transform:
            rotate(var(--unit-rotation))
            scale(1)
            translateX(0);
    }
}

.danger-zone-fighter .unit-sprite {
    filter:
        drop-shadow(0 0 8px rgba(180, 70, 255, 0.95))
        drop-shadow(0 0 18px rgba(120, 0, 255, 0.65))
        drop-shadow(0 0 28px rgba(255, 80, 255, 0.35));
}

.force-field-disabled .unit-sprite {
    opacity: 0.75;

    filter:
        drop-shadow(0 0 8px rgba(255, 50, 50, 0.95))
        drop-shadow(0 0 18px rgba(255, 0, 0, 0.7))
        drop-shadow(0 0 28px rgba(255, 120, 120, 0.35));
}

.power-matrix-dreadnought .unit-sprite {
    filter:
        drop-shadow(0 0 10px rgba(255, 180, 0, 0.95))
        drop-shadow(0 0 20px rgba(255, 100, 0, 0.75))
        drop-shadow(0 0 30px rgba(255, 255, 120, 0.45));
}

.mass-distortion-unit .unit-sprite {
    filter:
        drop-shadow(0 0 10px rgba(80, 255, 120, 0.95))
        drop-shadow(0 0 22px rgba(0, 255, 120, 0.7))
        drop-shadow(0 0 34px rgba(120, 255, 160, 0.35));
}

.mass-distortion-flash .unit-sprite {
    animation:
        massDistortionFlash 0.7s ease;
}

@keyframes massDistortionFlash {
    0% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1);
        filter:
            drop-shadow(0 0 8px rgba(255, 255, 255, 0.25));
    }

    45% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1.18);
        filter:
            drop-shadow(0 0 22px rgba(80, 255, 120, 1))
            drop-shadow(0 0 36px rgba(0, 255, 120, 0.8));
    }

    100% {
        opacity: 1;
        transform:
            rotate(var(--unit-rotation))
            scale(1);
        filter:
            drop-shadow(0 0 10px rgba(80, 255, 120, 0.95));
    }
}

.camouflaged-destruction-ghost {
    position: absolute;

    width: var(--hex-width);
    height: var(--hex-height);

    display: flex;
    justify-content: center;
    align-items: center;

    pointer-events: none;

    z-index: 80;
}

.camouflaged-destruction-ghost .unit-hp-bar {
    display: none;
}

.camouflaged-destruction-ghost .unit-sprite {
    opacity: 1 !important;
}

.harvester-unit .unit-sprite {
    filter:
        drop-shadow(0 0 12px rgba(255, 40, 40, 0.85))
        drop-shadow(0 0 28px rgba(120, 0, 0, 0.6));
}

.harvester-home-mode .unit-sprite {
    filter:
        drop-shadow(0 0 12px rgba(50, 220, 255, 0.95))
        drop-shadow(0 0 28px rgba(20, 100, 255, 0.65));
}

.harvester-neutral-mode .unit-sprite {
    filter:
        drop-shadow(0 0 12px rgba(255, 180, 40, 0.9))
        drop-shadow(0 0 28px rgba(255, 70, 20, 0.55));
}

.harvester-danger-mode .unit-sprite {
    filter:
        drop-shadow(0 0 14px rgba(255, 30, 30, 1))
        drop-shadow(0 0 30px rgba(255, 0, 0, 0.85))
        drop-shadow(0 0 44px rgba(130, 0, 0, 0.55));
}

.harvester-spawn-flash .unit-sprite {
    animation:
        harvesterSpawnFlash 1.1s ease;
}

.harvester-mode-flash .unit-sprite {
    animation:
        harvesterModeFlash 0.7s ease;
}

@keyframes harvesterSpawnFlash {
    0% {
        opacity: 0;

        transform:
            rotate(var(--unit-rotation))
            scale(0.1);

        filter:
            drop-shadow(0 0 12px rgba(255, 0, 0, 0));
    }

    45% {
        opacity: 1;

        transform:
            rotate(var(--unit-rotation))
            scale(1.35);

        filter:
            drop-shadow(0 0 30px rgba(255, 30, 30, 1))
            drop-shadow(0 0 55px rgba(120, 0, 0, 0.95));
    }

    100% {
        opacity: 1;

        transform:
            rotate(var(--unit-rotation))
            scale(1);

        filter:
            drop-shadow(0 0 14px rgba(255, 50, 50, 0.85));
    }
}

@keyframes harvesterModeFlash {
    0% {
        transform:
            rotate(var(--unit-rotation))
            scale(1);
    }

    50% {
        transform:
            rotate(var(--unit-rotation))
            scale(1.18);

        filter:
            drop-shadow(0 0 30px rgba(255, 255, 255, 0.95));
    }

    100% {
        transform:
            rotate(var(--unit-rotation))
            scale(1);
    }
}

.harvester-destruction-effect {
    position: absolute;

    left: 0;
    top: 0;

    width: calc(var(--hex-width) * 2.4);
    height: calc(var(--hex-height) * 2.4);

    object-fit: contain;

    pointer-events: none;

    z-index: 120;

    transform:
        translate(-50%, -50%);
}

.destroyed-unit-ghost {
    position: absolute;

    width: var(--hex-width);
    height: var(--hex-height);

    display: flex;
    justify-content: center;
    align-items: center;

    pointer-events: none;

    z-index: 125;

    transform:
        translate(-50%, -50%);
}

.destroyed-unit-ghost .unit-hp-bar {
    display: none;
}

/*Responsive Design */
/* K3PESH tablet board */
@media (max-width: 1100px) {

    #board-container {
        width:
            min(
                96vw,
                calc(100svh - 150px),
                920px
            );

        height: auto;

        aspect-ratio:
            1 / 1;

        flex:
            0 0 auto;
    }

    #k3pesh-board {
        width: 100%;
        height: 100%;
    }

    #top-bar {
        width:
            min(
                96vw,
                920px
            );

        flex-wrap: wrap;

        justify-content: center;

        gap: 10px;

        margin-bottom: 12px;
    }

    .timer {
        width: 130px;

        padding: 9px;

        font-size: 1rem;
    }

    #status-display {
        font-size: 0.9rem;

        letter-spacing: 2px;
    }

    #combat-announcer {
        flex-basis: 100%;

        max-width: none;

        min-height: 1.2em;

        padding:
            0 8px;

        font-size: 0.72rem;
    }
}

/* Phones board */
@media (max-width: 700px) {

    #board-container {
        width:
            min(
                98vw,
                calc(100svh - 135px)
            );
    }

    #top-bar {
        width: 98vw;

        gap: 6px;

        margin-bottom: 8px;
    }

    .timer {
        width:
            calc(50% - 10px);

        max-width: 150px;

        padding: 7px;

        font-size: 0.9rem;
    }

    #status-display {
        width: 100%;

        text-align: center;

        font-size: 0.78rem;

        letter-spacing: 1.5px;
    }

    #combat-announcer {
        width: 100%;

        font-size: 0.66rem;
    }

    .unit-type-homeworld {
        width: 90%;
        height: 90%;
    }
}