.fr {
    --fr-allied: 76, 175, 110;
    --fr-neutral: 214, 170, 44;
    --fr-hostile: 205, 72, 72;
    --fr-neon: 109, 255, 170;
    
    --fr-cell: clamp(1.7rem, calc((100vw - 28rem) / 13), 3.3rem);
    --fr-cell-h: 2.6rem;
    --fr-gap: 5px;

    position: relative;
    
    margin: 0 auto;
    width: fit-content;
    max-width: 100%;
    padding: 1.4rem 1.75rem 1.6rem;
    box-sizing: border-box;
    background: rgba(8, 10, 9, 0.78);
    border: 1px solid rgba(var(--fr-neon), 0.22);
}

.fr::before,
.fr::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    pointer-events: none;
    border: 0 solid rgba(var(--fr-neon), 0.7);
}

.fr::before {
    top: -1px;
    left: -1px;
    border-top-width: 2px;
    border-left-width: 2px;
}

.fr::after {
    right: -1px;
    bottom: -1px;
    border-right-width: 2px;
    border-bottom-width: 2px;
}

.fr--allied { --fr-tone: var(--fr-allied); }
.fr--neutral { --fr-tone: var(--fr-neutral); }
.fr--hostile { --fr-tone: var(--fr-hostile); }
.fr--unknown { --fr-tone: 130, 140, 135; }

.fr__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-bottom: 0.9rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid rgba(var(--fr-neon), 0.22);
}

.fr__title {
    margin: 0;
    font-family: "Share Tech Mono", "Consolas", monospace;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(180, 150, 100, 0.9);
}

.fr__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: "Share Tech Mono", "Consolas", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(200, 216, 205, 0.8);
}

.fr__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.fr__chip {
    display: block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    background: rgba(var(--fr-tone), 0.55);
    border: 1px solid rgba(var(--fr-tone), 0.9);
}

.fr__scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.fr__scroll::-webkit-scrollbar {
    display: none;
}

.fr__table {
    border-collapse: separate;
    border-spacing: var(--fr-gap);
    margin: 0;
}

.fr__corner {
    padding: 0;
}

.fr__colhead {
    width: var(--fr-cell);
    min-width: var(--fr-cell);
    padding: 0 0 0.6rem;
    vertical-align: bottom;
    text-align: center;
    font-family: "Share Tech Mono", "Consolas", monospace;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgba(160, 182, 168, 0.8);
    border-bottom: 2px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.fr__colhead abbr {
    text-decoration: none;
    cursor: help;
}

.fr__rowhead {
    padding: 0 1.25rem 0 0;
    text-align: left;
    font-weight: 400;
    white-space: nowrap;
    
    position: sticky;
    left: 0;
    z-index: 1;
    background: rgb(8, 10, 9);
}

.fr__faction {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.15rem 0.5rem 0.15rem 0.25rem;
    border-left: 2px solid transparent;
    color: rgba(232, 238, 233, 0.9);
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.fr__faction:hover,
.fr__faction:focus-visible {
    color: #fff;
}

.fr__faction:focus-visible {
    outline: 1px solid rgba(var(--fr-neon), 0.8);
    outline-offset: 1px;
}

.fr__logo {
    display: block;
    flex: none;
    width: 64px;
    height: 32px;
    object-fit: cover;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fr__name {
    font-family: "Chakra Petch", "Exo 2", system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.15;
}

.fr__abbr {
    display: none;
    font-family: "Share Tech Mono", "Consolas", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
}

.fr__cell {
    width: var(--fr-cell);
    min-width: var(--fr-cell);
    height: var(--fr-cell-h);
    padding: 0;
    border-radius: 2px;
    background: rgba(var(--fr-tone), 0.42);
    border: 1px solid rgba(var(--fr-tone), 0.7);
    cursor: default;
    transition: opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.fr__cell--self {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.fr__cell:not(.fr__cell--self):hover {
    background: rgba(var(--fr-tone), 0.7);
    border-color: rgb(var(--fr-tone));
}

:where(.fr__table:has(.fr__cell:hover, .fr__colhead:hover, .fr__rowhead:hover, .fr__rowhead:focus-within)) .fr__cell {
    opacity: 0.3;
}

.fr__table tr:has(.fr__cell:hover, .fr__rowhead:hover, .fr__rowhead:focus-within) > .fr__cell {
    opacity: 1;
}

.fr__table tr:has(.fr__cell:hover, .fr__rowhead:hover, .fr__rowhead:focus-within) .fr__faction {
    background: rgba(var(--fr-neon), 0.07);
    border-left-color: rgba(var(--fr-neon), 0.85);
    color: #fff;
}

.fr__table:has([data-c="1"]:hover, [data-r="1"]:hover, [data-r="1"]:focus-within) [data-c="1"],
.fr__table:has([data-c="2"]:hover, [data-r="2"]:hover, [data-r="2"]:focus-within) [data-c="2"],
.fr__table:has([data-c="3"]:hover, [data-r="3"]:hover, [data-r="3"]:focus-within) [data-c="3"],
.fr__table:has([data-c="4"]:hover, [data-r="4"]:hover, [data-r="4"]:focus-within) [data-c="4"],
.fr__table:has([data-c="5"]:hover, [data-r="5"]:hover, [data-r="5"]:focus-within) [data-c="5"],
.fr__table:has([data-c="6"]:hover, [data-r="6"]:hover, [data-r="6"]:focus-within) [data-c="6"],
.fr__table:has([data-c="7"]:hover, [data-r="7"]:hover, [data-r="7"]:focus-within) [data-c="7"],
.fr__table:has([data-c="8"]:hover, [data-r="8"]:hover, [data-r="8"]:focus-within) [data-c="8"],
.fr__table:has([data-c="9"]:hover, [data-r="9"]:hover, [data-r="9"]:focus-within) [data-c="9"],
.fr__table:has([data-c="10"]:hover, [data-r="10"]:hover, [data-r="10"]:focus-within) [data-c="10"],
.fr__table:has([data-c="11"]:hover, [data-r="11"]:hover, [data-r="11"]:focus-within) [data-c="11"],
.fr__table:has([data-c="12"]:hover, [data-r="12"]:hover, [data-r="12"]:focus-within) [data-c="12"],
.fr__table:has([data-c="13"]:hover, [data-r="13"]:hover, [data-r="13"]:focus-within) [data-c="13"],
.fr__table:has([data-c="14"]:hover, [data-r="14"]:hover, [data-r="14"]:focus-within) [data-c="14"],
.fr__table:has([data-c="15"]:hover, [data-r="15"]:hover, [data-r="15"]:focus-within) [data-c="15"],
.fr__table:has([data-c="16"]:hover, [data-r="16"]:hover, [data-r="16"]:focus-within) [data-c="16"] {
    opacity: 1;
}

.fr__table:has([data-c="1"]:hover, [data-r="1"]:hover, [data-r="1"]:focus-within) .fr__colhead[data-c="1"],
.fr__table:has([data-c="2"]:hover, [data-r="2"]:hover, [data-r="2"]:focus-within) .fr__colhead[data-c="2"],
.fr__table:has([data-c="3"]:hover, [data-r="3"]:hover, [data-r="3"]:focus-within) .fr__colhead[data-c="3"],
.fr__table:has([data-c="4"]:hover, [data-r="4"]:hover, [data-r="4"]:focus-within) .fr__colhead[data-c="4"],
.fr__table:has([data-c="5"]:hover, [data-r="5"]:hover, [data-r="5"]:focus-within) .fr__colhead[data-c="5"],
.fr__table:has([data-c="6"]:hover, [data-r="6"]:hover, [data-r="6"]:focus-within) .fr__colhead[data-c="6"],
.fr__table:has([data-c="7"]:hover, [data-r="7"]:hover, [data-r="7"]:focus-within) .fr__colhead[data-c="7"],
.fr__table:has([data-c="8"]:hover, [data-r="8"]:hover, [data-r="8"]:focus-within) .fr__colhead[data-c="8"],
.fr__table:has([data-c="9"]:hover, [data-r="9"]:hover, [data-r="9"]:focus-within) .fr__colhead[data-c="9"],
.fr__table:has([data-c="10"]:hover, [data-r="10"]:hover, [data-r="10"]:focus-within) .fr__colhead[data-c="10"],
.fr__table:has([data-c="11"]:hover, [data-r="11"]:hover, [data-r="11"]:focus-within) .fr__colhead[data-c="11"],
.fr__table:has([data-c="12"]:hover, [data-r="12"]:hover, [data-r="12"]:focus-within) .fr__colhead[data-c="12"],
.fr__table:has([data-c="13"]:hover, [data-r="13"]:hover, [data-r="13"]:focus-within) .fr__colhead[data-c="13"],
.fr__table:has([data-c="14"]:hover, [data-r="14"]:hover, [data-r="14"]:focus-within) .fr__colhead[data-c="14"],
.fr__table:has([data-c="15"]:hover, [data-r="15"]:hover, [data-r="15"]:focus-within) .fr__colhead[data-c="15"],
.fr__table:has([data-c="16"]:hover, [data-r="16"]:hover, [data-r="16"]:focus-within) .fr__colhead[data-c="16"] {
    color: #fff;
    border-bottom-color: rgba(var(--fr-neon), 0.85);
}

@media (max-width: 900px) {
    .fr__faction {
        gap: 0.4rem;
    }

    .fr__logo {
        width: 40px;
        height: 20px;
    }

    .fr__name {
        display: none;
    }

    .fr__abbr {
        display: inline;
    }
}

@media (max-width: 640px) {
    .fr {
        --fr-cell: clamp(1.4rem, calc((100vw - 18rem) / 13), 1.9rem);
        --fr-cell-h: 1.8rem;
        --fr-gap: 3px;
        width: 100%;
        padding: 0.8rem 0.6rem 0.9rem;
    }
}

@media (max-width: 480px) {
    .fr {
        --fr-cell: 1.42rem;
        --fr-cell-h: 1.6rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .fr__logo {
        display: none;
    }

    .fr__rowhead {
        padding-right: 0.15rem;
    }

    .fr__faction {
        padding: 0.1rem 0.25rem 0.1rem 0.15rem;
    }

    .fr__colhead {
        font-size: 0.62rem;
        letter-spacing: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fr__cell,
    .fr__colhead,
    .fr__faction {
        transition: none;
    }
}
