* {
    box-sizing: border-box;
}

:root {
    --bg: #101010;
    --panel: #1b1b1b;
    --panel-light: #252525;
    --border: #555;
    --text: #f2f2f2;
    --muted: #a0a0a0;
    --accent: #c7a64b;
    --faction-color: #c7a64b;
    --faction-image: none;

}

body {
    margin: 0;
    min-height: 100vh;

    background:
        linear-gradient(
            180deg,
            #090909,
            #181818
        );

    color: var(--text);

    font-family:
        Arial,
        Helvetica,
        sans-serif;
}

.app {
    width: 100%;
    max-width: 700px;

    margin: 0 auto;
    padding: 16px;
}

.header {
    text-align: center;
    padding:
        16px
        0
        24px;
}

.game-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 2px;
}

.game-subtitle {
    margin-top: 6px;

    color: var(--accent);

    font-size: 12px;
    letter-spacing: 4px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.screen-title {
    margin:
        20px
        0
        16px;

    text-align: center;

    font-size: 18px;
    font-weight: 800;

    letter-spacing: 1px;
}

.loading {
    min-height: 250px;
    padding: 54px 20px 70px;
    text-align: center;
    color: var(--muted);
}

.loading-orbit {
    position: relative;
    width: 58px;
    height: 58px;
    margin: 0 auto 25px;
    border: 2px solid rgba(199, 166, 75, 0.2);
    border-top-color: var(--accent);
    border-right-color: rgba(199, 166, 75, 0.75);
    border-radius: 50%;
    animation: game-loading-spin 1.1s linear infinite;
}

.loading-orbit::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(199, 166, 75, 0.35);
    border-bottom-color: var(--accent);
    border-radius: 50%;
    animation: game-loading-spin 1.7s linear infinite reverse;
}

.loading-orbit span {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.loading-title {
    margin-bottom: 25px;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.loading-progress-track {
    width: min(100%, 340px);
    height: 5px;
    margin: 0 auto 12px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.09);
}

.loading-progress-bar {
    width: 6%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8f7535, var(--accent), #f5df94);
    box-shadow: 0 0 12px rgba(199, 166, 75, 0.4);
    transition: width 0.6s ease;
}

.loading-progress-label {
    min-height: 18px;
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.loading-detail {
    max-width: 340px;
    min-height: 36px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

@keyframes game-loading-spin {
    to { transform: rotate(360deg); }
}

.faction-counter {
    text-align: center;

    color: var(--muted);

    margin-bottom: 14px;
}

.faction-card {
    min-height: 360px;

    padding: 24px;

    background:
        linear-gradient(
            180deg,
            var(--panel-light),
            var(--panel)
        );

    border:
        1px solid
        var(--border);

    border-radius: 14px;

    text-align: center;
}



.faction-card h1 {
    margin: 0 0 16px;

    font-size: 30px;

    color: var(--accent);
}

.faction-description {
    line-height: 1.6;

    color: #d0d0d0;
}

.faction-navigation {
    display: flex;

    justify-content: center;

    gap: 20px;

    margin: 18px 0;
}

.arrow-button {
    width: 70px;
    height: 52px;

    background: var(--panel);

    color: var(--text);

    border:
        1px solid
        var(--border);

    border-radius: 10px;

    font-size: 22px;

    cursor: pointer;
}

.main-button {
    width: 100%;

    margin-top: 14px;

    padding: 17px;

    border: none;

    border-radius: 10px;

    background: var(--accent);

    color: #111;

    font-weight: 900;

    font-size: 15px;

    letter-spacing: 1px;

    cursor: pointer;
}

.main-button:disabled {
    opacity: 0.6;
}

.secondary-button {
    width: 100%;

    margin-top: 12px;

    padding: 14px;

    background: transparent;

    border:
        1px solid
        var(--border);

    color: var(--text);

    border-radius: 10px;

    cursor: pointer;
}

.selected-faction {
    margin-bottom: 25px;

    text-align: center;

    font-size: 24px;

    color: var(--accent);
}

.input-label {
    display: block;

    margin:
        18px
        0
        8px;

    color: var(--muted);

    font-size: 12px;

    font-weight: 700;

    letter-spacing: 1px;
}

.game-input {
    width: 100%;

    padding: 15px;

    background: var(--panel);

    color: var(--text);

    border:
        1px solid
        var(--border);

    border-radius: 8px;

    font-size: 16px;
}

.game-input:focus {
    outline: none;

    border-color:
        var(--accent);
}

.profile-card {
    display: flex;

    align-items: center;

    gap: 16px;

    padding: 18px;

    background: var(--panel);

    border-radius: 12px;

    border:
        1px solid
        var(--border);
}

.avatar {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 58px;
    height: 58px;

    border-radius: 50%;

    background: #111;

    font-size: 28px;
}

.label,
.resource-name {
    color: var(--muted);

    font-size: 11px;

    letter-spacing: 1px;
}

.player-name {
    margin-top: 4px;

    font-size: 20px;

    font-weight: 800;
}

.player-faction {
    margin-top: 5px;

    color: var(--accent);
}

.resources h2 {
    margin-top: 28px;

    font-size: 17px;
}

.resource-grid {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 10px;
}

.resource-card {
    padding: 14px 8px;

    background: var(--panel);

    border-radius: 10px;

    border:
        1px solid
        var(--border);

    text-align: center;
}

.resource-icon {
    font-size: 22px;
}

.resource-value {
    margin-top: 8px;

    font-size: 19px;

    font-weight: 800;
}

.navigation {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 10px;

    margin-top: 28px;
}

.nav-button {
    min-height: 90px;

    background: var(--panel);

    color: var(--text);

    border:
        1px solid
        var(--border);

    border-radius: 10px;

    font-size: 25px;

    cursor: pointer;
}

.nav-button span {
    display: block;

    margin-top: 7px;

    font-size: 11px;
}

.footer {
    margin-top: 30px;

    padding: 12px;

    text-align: center;

    color: var(--muted);

    font-size: 11px;
}

.error-message {
    padding: 50px 20px;

    text-align: center;

    color: #ff7777;
}


/* ============================================================
   ФРАКЦИОННАЯ АТМОСФЕРА
============================================================ */

body {
    position: relative;

    transition:
        background 0.7s ease,
        color 0.4s ease;
}

body::before {
    content: "";

    position: fixed;

    inset: 0;

    z-index: -2;

    background:
        linear-gradient(
            180deg,
            rgba(5, 5, 8, 0.72),
            rgba(10, 10, 14, 0.96)
        ),
        var(--faction-image);

    background-size: cover;

    background-position: center;

    background-repeat: no-repeat;

    filter: brightness(0.75);

    opacity: 0.32;

    transition:
        background 0.8s ease,
        opacity 0.8s ease;
}

body::after {
    content: "";

    position: fixed;

    inset: 0;

    z-index: -1;

    background:
        radial-gradient(
            circle at top,
            color-mix(
                in srgb,
                var(--faction-color) 18%,
                transparent
            ),
            transparent 55%
        );

    pointer-events: none;
}


/* ============================================================
   КАРТОЧКА ФРАКЦИИ
============================================================ */

.faction-card {
    position: relative;

    overflow: hidden;

    background:
        linear-gradient(
            180deg,
            rgba(30, 30, 35, 0.88),
            rgba(10, 10, 14, 0.94)
        );

    border-color:
        color-mix(
            in srgb,
            var(--faction-color) 60%,
            #444
        );

    box-shadow:
        0 0 30px
        color-mix(
            in srgb,
            var(--faction-color) 18%,
            transparent
        );

    transition:
        border-color 0.5s ease,
        box-shadow 0.5s ease,
        transform 0.35s ease;
}

.faction-card::before {
    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            135deg,
            color-mix(
                in srgb,
                var(--faction-color) 12%,
                transparent
            ),
            transparent 45%
        );

    pointer-events: none;
}


/* ============================================================
   ИЗОБРАЖЕНИЕ ФРАКЦИИ
============================================================ */

.faction-image-placeholder {
    position: relative;

    width: 100%;

    height: 260px;

    margin:
        0 auto
        24px;

    overflow: hidden;

    border-radius: 14px;

    background: #080808;

    border:
        2px solid
        var(--faction-color);

    box-shadow:
        0 0 30px
        color-mix(
            in srgb,
            var(--faction-color) 35%,
            transparent
        );

    transition:
        border-color 0.5s ease,
        box-shadow 0.5s ease;
}

.faction-image-placeholder::after {
    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            to top,
            rgba(0, 0, 0, 0.65),
            transparent 55%
        );

    pointer-events: none;
}

.faction-image-placeholder img {
    width: 100%;

    height: 100%;

    display: block;

    object-fit: cover;

    animation:
        factionImageAppear
        0.55s ease;
}




/* ============================================================
   ЭМБЛЕМА ФРАКЦИИ
============================================================ */

.faction-image-placeholder {
    position: relative;

    isolation: isolate;
}


.faction-background-image {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;

    z-index: 1;

    animation:
        factionImageAppear
        0.55s ease;
}


.faction-image-overlay {
    position: absolute;

    inset: 0;

    z-index: 2;

    background:
        linear-gradient(
            180deg,
            rgba(0, 0, 0, 0.12),
            rgba(0, 0, 0, 0.72)
        );

    pointer-events: none;
}


.faction-emblem {
    position: absolute;

    left: 50%;
    top: 50%;

    z-index: 3;

    width: min(58%, 210px);
    height: min(58%, 210px);

    transform:
        translate(-50%, -50%);

    object-fit: contain;

    filter:
        drop-shadow(
            0 0 10px
            color-mix(
                in srgb,
                var(--faction-color) 70%,
                transparent
            )
        )
        drop-shadow(
            0 0 28px
            color-mix(
                in srgb,
                var(--faction-color) 45%,
                transparent
            )
        );

    animation:
        factionEmblemAppear
        0.6s ease;

    transition:
        filter 0.45s ease,
        transform 0.35s ease;
}


.faction-emblem:hover {
    transform:
        translate(-50%, -50%)
        scale(1.06);
}


@keyframes factionEmblemAppear {

    0% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(0.72);
    }

    70% {
        opacity: 1;

        transform:
            translate(-50%, -50%)
            scale(1.06);
    }

    100% {
        opacity: 1;

        transform:
            translate(-50%, -50%)
            scale(1);
    }
}


/* ============================================================
   ТЕКСТ ФРАКЦИИ
============================================================ */

.faction-card h1 {
    color: var(--faction-color);

    text-shadow:
        0 0 16px
        color-mix(
            in srgb,
            var(--faction-color) 55%,
            transparent
        );

    transition:
        color 0.4s ease;
}


/* ============================================================
   КНОПКИ
============================================================ */

.main-button {
    background: var(--faction-color);

    box-shadow:
        0 0 18px
        color-mix(
            in srgb,
            var(--faction-color) 35%,
            transparent
        );

    transition:
        background 0.4s ease,
        transform 0.2s ease,
        box-shadow 0.4s ease;
}

.main-button:active {
    transform: scale(0.98);
}

.arrow-button:hover {
    border-color: var(--faction-color);

    box-shadow:
        0 0 14px
        color-mix(
            in srgb,
            var(--faction-color) 35%,
            transparent
        );
}


/* ============================================================
   АНИМАЦИИ
============================================================ */

.faction-transition {
    animation:
        factionCardSwitch
        0.45s ease;
}

@keyframes factionCardSwitch {

    0% {
        opacity: 0.45;
        transform:
            translateY(8px)
            scale(0.985);
    }

    100% {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

@keyframes factionImageAppear {

    0% {
        opacity: 0;
        transform:
            scale(1.06);
    }

    100% {
        opacity: 1;
        transform:
            scale(1);
    }
}


/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ
============================================================ */

@media (max-width: 600px) {

    .faction-image-placeholder {
        height: 230px;
    }

}




/* =========================================================
   ФОН ФРАКЦИИ ВО ВРЕМЯ ИГРЫ
   ========================================================= */

#game-screen {
    position: relative;
    isolation: isolate;

    min-height: 100vh;

    background: transparent;

    transition:
        background 0.35s ease;
}


/* Игровой интерфейс всегда находится над изображением */

#game-screen > * {
    position: relative;
    z-index: 1;
}

/* FACTION FULLSCREEN BACKGROUND START */

/* =========================================================
   ПОЛНОЭКРАННЫЙ ФОН ВЫБРАННОЙ ФРАКЦИИ
   ========================================================= */

#faction-screen {
    position: relative;
    isolation: isolate;

    min-height: 100vh;

    background-image:
        linear-gradient(
            rgba(5, 10, 8, 0.68),
            rgba(5, 8, 12, 0.88)
        ),
        var(--faction-image);

    background-size:
        cover,
        cover;

    background-position:
        center,
        center;

    background-repeat:
        no-repeat,
        no-repeat;

    transition:
        background-image 0.35s ease;
}


/* Все элементы должны быть فوق фоновой картинки */

#faction-screen > * {
    position: relative;
    z-index: 1;
}


/* =========================================================
   КАРТОЧКА ФРАКЦИИ
   ========================================================= */

.faction-card {
    background:
        linear-gradient(
            180deg,
            rgba(8, 12, 16, 0.55),
            rgba(8, 10, 14, 0.82)
        );

    backdrop-filter:
        blur(5px);

    -webkit-backdrop-filter:
        blur(5px);
}


/* =========================================================
   ВНУТРЕННЕЕ ОКНО С ЭМБЛЕМОЙ
   ========================================================= */

.faction-image-placeholder {
    position: relative;

    overflow: hidden;

    background:
        rgba(0, 0, 0, 0.45);
}


/*
   Большая фоновая картинка внутри карточки больше
   не нужна — основной фон теперь занимает весь экран.
*/

.faction-background-image {
    display: none;
}


/* Затемнение внутри блока эмблемы */

.faction-image-overlay {
    position: absolute;

    inset: 0;

    background:
        radial-gradient(
            circle,
            rgba(0, 0, 0, 0.10),
            rgba(0, 0, 0, 0.65)
        );

    z-index: 1;
}


/* =========================================================
   ЭМБЛЕМА ФРАКЦИИ
   ========================================================= */

.faction-emblem {
    position: absolute;

    left: 50%;
    top: 50%;

    transform:
        translate(-50%, -50%);

    z-index: 2;

    width: 72%;
    height: 72%;

    object-fit: contain;

    filter:
        drop-shadow(
            0 0 12px var(--faction-color)
        )
        drop-shadow(
            0 0 28px rgba(0, 0, 0, 0.9)
        );
}


/* Дополнительное свечение фракции */

.faction-card {
    border-color:
        color-mix(
            in srgb,
            var(--faction-color) 70%,
            transparent
        );

    box-shadow:
        0 0 20px rgba(0, 0, 0, 0.65),
        0 0 35px color-mix(
            in srgb,
            var(--faction-color) 22%,
            transparent
        );
}

/* FACTION FULLSCREEN BACKGROUND END */



/* HEADER FACTION EMBLEM START */

/* =========================================================
   ЭМБЛЕМА ФРАКЦИИ В ВЕРХНЕЙ ШАПКЕ
   ========================================================= */

.header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-faction-emblem {
    width: 64px;
    height: 64px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-radius: 10px;

    background:
        rgba(5, 12, 10, 0.72);

    border:
        1px solid
        rgba(255, 255, 255, 0.10);

    box-shadow:
        0 0 18px
        rgba(0, 0, 0, 0.35);
}

.header-faction-emblem img {
    width: 100%;
    height: 100%;

    object-fit: contain;

    display: block;

    padding: 3px;
}

.header-title-wrapper {
    flex: 1;
    min-width: 0;
}


/* =========================================================
   ГЕРБ + НАСТРОЙКИ
   ========================================================= */

.header-faction-controls {
    flex-shrink: 0;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 5px;

    position: relative;
}

/* =========================================================
   КНОПКА НАСТРОЕК
   ========================================================= */

.settings-wrapper {
    position: relative;

    display: flex;
    justify-content: center;
}

.settings-button {
    width: 34px;
    height: 30px;

    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border:
        1px solid
        rgba(255, 255, 255, 0.10);

    border-radius: 7px;

    background:
        rgba(5, 12, 10, 0.72);

    color:
        rgba(255, 255, 255, 0.70);

    font-family: inherit;
    font-size: 17px;
    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 0 12px
        rgba(0, 0, 0, 0.30);

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease,
        border-color 0.2s ease;
}

.settings-button:hover {
    color: #ffffff;

    background:
        rgba(255, 255, 255, 0.08);

    border-color:
        rgba(255, 255, 255, 0.20);
}

.settings-button:active {
    transform: scale(0.94);
}


/* =========================================================
   МЕНЮ НАСТРОЕК
   ========================================================= */

.settings-menu {
    position: absolute;

    top: calc(100% + 7px);
    left: 0;

    width: 190px;

    z-index: 1000;

    padding: 10px;

    border:
        1px solid
        rgba(255, 255, 255, 0.12);

    border-radius: 9px;

    background:
        rgba(5, 12, 10, 0.96);

    box-shadow:
        0 8px 28px
        rgba(0, 0, 0, 0.45);

    backdrop-filter: blur(8px);
}

.settings-menu[hidden] {
    display: none;
}

.settings-menu-title {
    padding:
        2px
        4px
        8px;

    color:
        #ffffff;

    font-size: 11px;
    font-weight: 700;

    letter-spacing: 0.08em;

    border-bottom:
        1px solid
        rgba(255, 255, 255, 0.08);
}

.settings-section {
    padding-top: 9px;
}

.admin-account-actions {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.settings-section-title {
    margin-bottom: 6px;
    padding-left: 4px;

    color:
        rgba(255, 255, 255, 0.55);

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 0.08em;
}


/* =========================================================
   ВЫБОР ЯЗЫКА
   ========================================================= */

.language-selector {
    display: flex;
    align-items: center;

    gap: 3px;

    width: 100%;

    padding: 3px;

    border:
        1px solid
        rgba(255, 255, 255, 0.08);

    border-radius: 7px;

    background:
        rgba(0, 0, 0, 0.20);
}

.language-option {
    flex: 1;

    min-width: 34px;
    height: 28px;

    padding: 0 6px;

    border: 0;
    border-radius: 5px;

    background: transparent;

    color:
        rgba(255, 255, 255, 0.55);

    font-family: inherit;
    font-size: 11px;
    font-weight: 700;

    letter-spacing: 0.04em;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.language-option:hover {
    color:
        rgba(255, 255, 255, 0.90);

    background:
        rgba(255, 255, 255, 0.08);
}

.language-option.active {
    color:
        #ffffff;

    background:
        color-mix(
            in srgb,
            var(--faction-color) 70%,
            rgba(255, 255, 255, 0.08)
        );

    box-shadow:
        0 0 8px
        color-mix(
            in srgb,
            var(--faction-color) 35%,
            transparent
        );
}

.language-option:active {
    transform:
        scale(0.94);
}


/* Мобильная версия */

@media (max-width: 600px) {

    .header-faction-emblem {
        width: 58px;
        height: 58px;
    }

    .settings-button {
        width: 31px;
        height: 27px;

        font-size: 15px;
    }

    .settings-menu {
        width: 180px;
    }

    .header {
        gap: 10px;
    }

}
 
 
/* HEADER FACTION EMBLEM END */


/* FACTION SWITCH ANIMATION START */

/* =========================================================
   АНИМАЦИЯ ПЕРЕКЛЮЧЕНИЯ ФРАКЦИЙ
   ========================================================= */

.faction-card {
    will-change:
        transform,
        opacity,
        box-shadow;
}


/* Исчезновение старой фракции */

.faction-card.faction-leaving {
    animation:
        factionLeave
        0.18s
        ease-in
        forwards;
}


/* Появление новой фракции */

.faction-card.faction-entering {
    animation:
        factionEnter
        0.42s
        cubic-bezier(0.22, 1, 0.36, 1)
        forwards;
}


/* Анимация фонового изображения */

#faction-screen.faction-background-transition {
    animation:
        factionBackgroundPulse
        0.65s
        ease-out;
}


/* Фоновая картинка внутри карточки */

.faction-background-image {
    transition:
        opacity 0.35s ease,
        transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);

    will-change:
        opacity,
        transform;
}


.faction-card.faction-entering
.faction-background-image {
    animation:
        factionBackgroundZoom
        0.65s
        cubic-bezier(0.22, 1, 0.36, 1)
        forwards;
}


/* Эмблема */

.faction-emblem {
    will-change:
        transform,
        opacity,
        filter;
}


.faction-card.faction-entering
.faction-emblem {
    animation:
        factionEmblemAppear
        0.55s
        cubic-bezier(0.22, 1, 0.36, 1)
        forwards;
}


/* Эмблема в header */

#header-faction-emblem {
    visibility: hidden;
}

#header-faction-emblem.loaded {
    visibility: visible;
}

#header-faction-emblem {
    will-change:
        transform,
        opacity;
}


.header-faction-emblem.emblem-switching
#header-faction-emblem {
    animation:
        headerEmblemSwitch
        0.5s
        cubic-bezier(0.22, 1, 0.36, 1);
}


/* Название */

.faction-card.faction-entering
#faction-name {
    animation:
        factionTextAppear
        0.45s
        0.08s
        both;
}


/* Описание */

.faction-card.faction-entering
#faction-description {
    animation:
        factionTextAppear
        0.5s
        0.15s
        both;
}


/* =========================================================
   KEYFRAMES
   ========================================================= */

@keyframes factionLeave {

    from {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }

    to {
        opacity: 0;
        transform:
            translateY(-10px)
            scale(0.985);
    }

}


@keyframes factionEnter {

    from {
        opacity: 0;
        transform:
            translateY(18px)
            scale(0.985);
        box-shadow:
            0 0 0
            rgba(0, 0, 0, 0);
    }

    to {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
        box-shadow:
            0 0 28px
            color-mix(
                in srgb,
                var(--faction-color) 32%,
                transparent
            );
    }

}


@keyframes factionBackgroundZoom {

    from {
        opacity: 0;
        transform:
            scale(1.08);
    }

    to {
        opacity: 1;
        transform:
            scale(1);
    }

}


@keyframes factionEmblemAppear {

    from {
        opacity: 0;
        transform:
            scale(0.65)
            rotate(-8deg);
        filter:
            brightness(1.8)
            blur(2px);
    }

    to {
        opacity: 1;
        transform:
            scale(1)
            rotate(0deg);
        filter:
            brightness(1)
            blur(0);
    }

}


@keyframes factionTextAppear {

    from {
        opacity: 0;
        transform:
            translateY(12px);
    }

    to {
        opacity: 1;
        transform:
            translateY(0);
    }

}


@keyframes headerEmblemSwitch {

    0% {
        opacity: 0;
        transform:
            scale(0.65)
            rotate(-12deg);
    }

    55% {
        opacity: 1;
        transform:
            scale(1.15)
            rotate(4deg);
    }

    100% {
        opacity: 1;
        transform:
            scale(1)
            rotate(0deg);
    }

}


@keyframes factionBackgroundPulse {

    0% {
        filter:
            brightness(1);
    }

    35% {
        filter:
            brightness(1.12);
    }

    100% {
        filter:
            brightness(1);
    }

}


/* =========================================================
   МОБИЛЬНЫЕ УСТРОЙСТВА
   ========================================================= */

@media (max-width: 600px) {

    .faction-card.faction-entering {
        animation-duration:
            0.36s;
    }

}


/* =========================================================
   ACCESSIBILITY
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration:
            0.01ms !important;

        animation-iteration-count:
            1 !important;

        transition-duration:
            0.01ms !important;
    }

}

/* FACTION SWITCH ANIMATION END */

/* FACTION IMAGE EMBLEM TOGGLE START */

/* =========================================================
   ЦЕНТРАЛЬНЫЙ КВАДРАТ — КАРТИНКА / ЗНАМЯ
   ========================================================= */

.faction-image-placeholder {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}


/* ОСНОВНАЯ КАРТИНКА ФРАКЦИИ */

.faction-main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;

    animation:
        factionMainImageAppear
        0.45s
        cubic-bezier(0.22, 1, 0.36, 1);
}


/* ЗНАМЯ ФРАКЦИИ */

.faction-emblem-full {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 16px;
    display: block;

    animation:
        factionFullEmblemAppear
        0.45s
        cubic-bezier(0.22, 1, 0.36, 1);

    filter:
        drop-shadow(
            0 0 14px
            var(--faction-color)
        )
        drop-shadow(
            0 0 28px
            rgba(0, 0, 0, 0.9)
        );
}


/* АНИМАЦИЯ ОБМЕНА */

.faction-image-placeholder.faction-content-switching {
    animation:
        factionContentSwitch
        0.45s
        cubic-bezier(0.22, 1, 0.36, 1);
}


@keyframes factionContentSwitch {

    0% {
        transform: scale(1);
        opacity: 1;
    }

    35% {
        transform: scale(0.96);
        opacity: 0.35;
    }

    70% {
        transform: scale(1.025);
        opacity: 0.9;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}


@keyframes factionMainImageAppear {

    from {
        opacity: 0;
        transform: scale(1.08);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


@keyframes factionFullEmblemAppear {

    from {
        opacity: 0;

        transform:
            scale(0.72)
            rotate(-5deg);
    }

    70% {
        opacity: 1;

        transform:
            scale(1.06)
            rotate(1deg);
    }

    to {
        opacity: 1;

        transform:
            scale(1)
            rotate(0);
    }
}


/* ВИЗУАЛЬНЫЙ ИНДИКАТОР НАЖАТИЯ */

.faction-image-placeholder:hover {

    border-color:
        color-mix(
            in srgb,
            var(--faction-color) 90%,
            white
        );

    box-shadow:
        0 0 38px
        color-mix(
            in srgb,
            var(--faction-color) 45%,
            transparent
        );
}


.faction-image-placeholder:active {
    transform: scale(0.985);
}

/* FACTION IMAGE EMBLEM TOGGLE END */


/* =========================================================
   FACTION CONTENT SMOOTH CROSSFADE START
   ========================================================= */

.faction-image-placeholder {
    position: relative;
}


/* Оба изображения могут накладываться друг на друга */

.faction-image-placeholder
.faction-main-image,
.faction-image-placeholder
.faction-emblem-full {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;
}


/* =========================================================
   ПОЯВЛЕНИЕ НОВОГО СОДЕРЖИМОГО
   ========================================================= */

.faction-content-entering {

    z-index: 3;

    animation:
        factionContentEnter
        0.55s
        cubic-bezier(0.22, 1, 0.36, 1)
        forwards;
}


@keyframes factionContentEnter {

    from {
        opacity: 0;

        transform:
            scale(1.08);
    }

    to {
        opacity: 1;

        transform:
            scale(1);
    }
}


/* =========================================================
   ИСЧЕЗНОВЕНИЕ СТАРОГО СОДЕРЖИМОГО
   ========================================================= */

.faction-content-leaving {

    z-index: 2;

    animation:
        factionContentLeave
        0.45s
        ease-in
        forwards;
}


@keyframes factionContentLeave {

    from {
        opacity: 1;

        transform:
            scale(1);
    }

    to {
        opacity: 0;

        transform:
            scale(0.94);
    }
}


/* =========================================================
   FACTION CONTENT SMOOTH CROSSFADE END
   ========================================================= */



/* FACTION REAL CROSSFADE START */

/* =========================================================
   НАСТОЯЩИЙ CROSSFADE
   ========================================================= */

.faction-image-placeholder {
    position: relative;
    overflow: hidden;
}


/* Оба элемента находятся друг над другом */

.faction-image-placeholder
.faction-main-image,

.faction-image-placeholder
.faction-emblem-full {

    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    transition:
        opacity 0.75s ease,
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}


/* =========================================================
   НОВЫЙ ЭЛЕМЕНТ
   ========================================================= */

.faction-crossfade-new {

    opacity: 0;

    transform:
        scale(1.08);

    z-index: 5;
}


/* После активации плавно появляется */

.faction-crossfade-new.faction-crossfade-active {

    opacity: 1;

    transform:
        scale(1);
}


/* =========================================================
   СТАРЫЙ ЭЛЕМЕНТ
   ========================================================= */

.faction-crossfade-old {

    opacity: 0 !important;

    transform:
        scale(0.94) !important;

    z-index: 4;
}


/* =========================================================
   ПОСЛЕ ПЕРЕХОДА
   ========================================================= */

.faction-image-placeholder
.faction-main-image:not(.faction-crossfade-new),

.faction-image-placeholder
.faction-emblem-full:not(.faction-crossfade-new) {

    opacity: 1;

    transform:
        scale(1);
}


/* FACTION REAL CROSSFADE END */\n
/* ============================================================
   FACTION SCREEN — FULLSCREEN ART WITHOUT CARDS
   ============================================================ */

#faction-screen {
    position: relative;
    isolation: isolate;
    min-height: 100vh;

    background-image:
        linear-gradient(
            180deg,
            rgba(4, 5, 12, 0.42) 0%,
            rgba(4, 5, 12, 0.16) 38%,
            rgba(4, 5, 12, 0.52) 72%,
            rgba(4, 5, 12, 0.88) 100%
        ),
        var(--faction-image);

    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

/* Картинка больше не является отдельным блоком */
#faction-screen .faction-image-placeholder {
    display: none !important;
}

/* Старую карточку превращаем в прозрачный контейнер */
#faction-screen .faction-card {
    position: relative;

    width: 100%;
    min-height: 0;

    margin: 0;
    padding: 80px 24px 110px;

    background: transparent !important;

    border: none !important;
    border-radius: 0 !important;

    box-shadow: none !important;

    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    text-align: center;
}

/* Старое декоративное оформление карточки полностью убираем */
#faction-screen .faction-card::before {
    display: none !important;
}

/* Название находится непосредственно поверх изображения */
#faction-screen #faction-name {
    position: relative;

    margin: 0 auto 22px;

    font-size: clamp(34px, 8vw, 54px);
    line-height: 1.1;

    color: var(--accent);

    text-shadow:
        0 2px 12px rgba(0, 0, 0, 0.95),
        0 0 24px
        color-mix(
            in srgb,
            var(--faction-color) 40%,
            transparent
        );
}

/* Описание непосредственно поверх изображения */
#faction-screen #faction-description {
    position: relative;

    max-width: 760px;

    margin: 0 auto;

    color: #f0f0f0;

    font-size: clamp(18px, 4.5vw, 25px);
    line-height: 1.55;

    text-align: center;

    text-shadow:
        0 2px 8px rgba(0, 0, 0, 0.95),
        0 0 18px rgba(0, 0, 0, 0.85);
}

/* Никаких дополнительных фоновых окон */
#faction-screen .faction-background-image,
#faction-screen .faction-image-overlay {
    display: none !important;
}

@media (max-width: 600px) {

    #faction-screen .faction-card {
        padding: 90px 20px 110px;
    }

    #faction-screen #faction-name {
        font-size: 40px;
    }

    #faction-screen #faction-description {
        font-size: 19px;
        line-height: 1.55;
    }
}


/* ============================================================
   GALAXY MAP
   ============================================================ */

.galaxy-map-screen {
    width: 100%;
    min-height: 70vh;
    margin-top: 0;
}

.galaxy-map-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.galaxy-map-back {
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.45);
    color: inherit;
    cursor: pointer;
}

.galaxy-map-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

#galaxy-map-level {
    font-weight: 700;
    letter-spacing: 0.08em;
}

#galaxy-map-object-name {
    opacity: 0.72;
    font-size: 0.9em;
}

.galaxy-map canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.galaxy-map-viewport {
    pointer-events: none;
    z-index: 0;
}

.galaxy-map-screen:not(.galaxy-map-fallback) .galaxy-map-viewport {
    display: none;
}

.galaxy-map-screen:not(.galaxy-map-fallback) .galaxy-map-viewport .galaxy-sector-marker,
.galaxy-map-screen:not(.galaxy-map-fallback) .galaxy-map-viewport .galaxy-planet-marker {
    display: none;
}

.galaxy-map-screen:not(.galaxy-map-fallback) .galaxy-map-viewport .galaxy-planet-sectors-layer {
    display: none;
}

.galaxy-map-screen.galaxy-map-fallback .galaxy-map-viewport {
    pointer-events: auto;
    z-index: 2;
}

.galaxy-map-screen.galaxy-map-fallback .galaxy-map-layer {
    pointer-events: auto;
}

.galaxy-map {
    position: relative;
    width: 100%;
    min-height: 60vh;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background:
        radial-gradient(
            circle at center,
            rgba(70, 70, 90, 0.18),
            rgba(0, 0, 0, 0.72)
        );
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.galaxy-map:active {
    cursor: grabbing;
}


/* ============================================================
   GALAXY MAP OBJECTS
   ============================================================ */

.galaxy-map-viewport {
    position: absolute;
    inset: 0;
    transform-origin: center center;
    transition: transform 0.08s ease-out;
}

.galaxy-map-layer {
    position: absolute;
    inset: 24px;
    min-width: 0;
    min-height: 0;
}

.galaxy-sector-marker,
.galaxy-planet-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 5px 8px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.galaxy-sector-dot,
.galaxy-planet-dot {
    display: block;
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border-radius: 50%;
    background: rgba(190, 190, 210, 0.95);
    box-shadow:
        0 0 5px rgba(220, 220, 240, 0.7);
}

.galaxy-sector-marker:hover .galaxy-sector-dot,
.galaxy-sector-marker:focus-visible .galaxy-sector-dot {
    transform: scale(1.45);
}

.galaxy-sector-label {
    font-size: 11px;
    line-height: 1.2;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.95);
    pointer-events: none;
}

.galaxy-planet-marker {
    min-height: 36px;
    padding: 4px 6px;
}

.galaxy-planet-dot {
    width: 7px;
    height: 7px;
    flex-basis: 7px;
    background: rgba(210, 210, 220, 0.95);
}

.galaxy-system-layer {
    display: block;
}

.galaxy-system-star {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    line-height: 1;
    text-shadow:
        0 0 8px rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

.galaxy-map-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    opacity: 0.75;
}



.galaxy-planet-sectors-button {
    width: 100%;
    min-height: 44px;
    margin-top: 14px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    color: inherit;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.galaxy-planet-sectors-button:hover,
.galaxy-planet-sectors-button:focus-visible {
    border-color: var(--accent);
}

.galaxy-planet-sectors-layer {
    display: grid;
    align-content: center;
    gap: 12px;
    padding: 24px;
    overflow: auto;
}

.galaxy-planet-sector-card {
    min-height: 118px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.42);
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.22);
}

.galaxy-planet-sector-number {
    opacity: 0.65;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
}

.galaxy-planet-sector-type {
    margin-top: 8px;
    font-size: 1rem;
    font-weight: 800;
}

.galaxy-planet-sector-city {
    margin-top: 8px;
    opacity: 0.78;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .galaxy-planet-sectors-layer {
        grid-template-columns: 1fr !important;
        padding: 14px;
    }
}

.galaxy-planet-info {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
}

.galaxy-planet-info-title {
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}

.galaxy-planet-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.galaxy-planet-info-grid > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.galaxy-planet-info-grid span {
    opacity: 0.65;
    font-size: 0.78rem;
}

.galaxy-planet-info-grid strong {
    overflow-wrap: anywhere;
}

@media (max-width: 520px) {
    .galaxy-planet-info-grid {
        grid-template-columns: 1fr;
    }
}


.auth-panel {
    width: min(92vw, 520px);
    margin: 24px auto;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.42);
    box-sizing: border-box;
}

.auth-message {
    min-height: 24px;
    margin-bottom: 16px;
    line-height: 1.45;
}

.auth-divider {
    margin: 22px 0 14px;
    text-align: center;
    opacity: 0.7;
    font-size: 12px;
    letter-spacing: 0.08em;
}

.auth-panel .main-button,
.auth-panel .secondary-button {
    width: 100%;
    margin-top: 12px;
}


/* ============================================================
   КОМАНДЫ РАЗРАБОТЧИКА
============================================================ */

#admin-screen {
    min-height: 70vh;
}

.admin-panel {
    padding: 18px;
    background: rgba(20, 20, 24, 0.94);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.admin-account-note {
    margin-bottom: 16px;
    padding: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    line-height: 1.5;
    font-size: 12px;
}


.admin-command-input {
    margin-top: 10px;
    font-family: monospace;
    font-size: 14px;
}

.admin-command-button {
    width: 100%;
    min-height: 54px;
    margin-top: 10px;
    padding: 13px 14px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.admin-command-button:hover {
    border-color: var(--accent);
}

.admin-command-button:disabled {
    opacity: 0.55;
    cursor: default;
}

.admin-command-pending {
    opacity: 0.65;
}

.admin-command-group {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-command-group-title {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}

.admin-output {
    margin-top: 18px;
    padding: 12px;
    min-height: 42px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 12px;
}

.developer-command-button {
    border-color: var(--accent);
    color: var(--accent);
}


.admin-diagnostics-output {
    margin: 10px 0 0;
    padding: 10px;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font: 12px/1.45 monospace;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
}


/* Map-first strategic interface: compact profile/resources stay available above the map. */
#nav-cities[hidden] {
    display: none !important;
}

.galaxy-map-screen {
    min-height: calc(100dvh - 140px);
    margin-top: 0;
}

.galaxy-map-hud {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: rgba(10, 14, 22, 0.94);
    color: var(--text);
    font-size: 12px;
}

.galaxy-map-hud-profile {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 3px;
}

.galaxy-map-hud-profile strong,
.galaxy-map-hud-profile span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.galaxy-map-hud-profile span {
    color: var(--muted);
}

.galaxy-map-hud-resources {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.galaxy-map-hud-resources > span {
    white-space: nowrap;
}

.galaxy-map-hud-resources b {
    font-variant-numeric: tabular-nums;
}

.galaxy-map {
    position: relative;
    z-index: 1;
    margin-top: 0;
    margin-bottom: 0;
    min-height: min(68vh, 760px);
    border-top: 0;
    border-radius: 0 0 12px 12px;
}

/* Secondary actions live directly below the strategic map. */
.galaxy-map-screen > .navigation {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    margin-top: 10px;
}

.galaxy-map-screen > .navigation .nav-button {
    min-height: 58px;
    padding: 7px 4px;
    border-radius: 8px;
    font-size: 19px;
}

.galaxy-map-screen > .navigation .nav-button span {
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.2;
}

@media (max-width: 560px) {
    .galaxy-map {
        min-height: 63vh;
    }

    .galaxy-map-screen > .navigation {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .galaxy-map-screen > .navigation .nav-button {
        min-height: 52px;
        font-size: 17px;
    }

    .galaxy-map-screen > .navigation .nav-button span {
        font-size: 9px;
    }
}

#galaxy-object-info {
    max-height: min(36vh, 310px);
    overflow-y: auto;
    pointer-events: auto !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

@media (max-width: 560px) {
    .galaxy-map-screen {
        min-height: calc(100dvh - 110px);
        margin-top: 0;
    }

    .galaxy-map-header {
        gap: 8px;
        margin-bottom: 0;
    }

    .galaxy-map-back {
        min-height: 38px;
        padding: 6px 9px;
        font-size: 12px;
    }

    .galaxy-map-hud {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
        padding: 7px 9px;
    }

    .galaxy-map-hud-resources {
        justify-content: flex-start;
        gap: 6px 9px;
        width: 100%;
        font-size: 11px;
    }

    .galaxy-map {
        min-height: 63vh;
        margin-top: 0;
        border-top: 0;
        border-radius: 0 0 8px 8px;
    }

    #galaxy-object-info {
        left: 8px !important;
        right: 8px !important;
        bottom: max(8px, env(safe-area-inset-bottom)) !important;
        max-height: 40vh;
        font-size: 12px;
    }
}


/* Planetary surface legend: compact and readable on desktop and mobile. */
.galaxy-map-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 14px;
    margin: 8px 2px 0;
    color: var(--muted);
    font-size: 11px;
}

.galaxy-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.galaxy-map-legend i {
    display: inline-block;
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 6px currentColor;
}

.galaxy-map-legend .legend-major-sector {
    color: #f1fff7;
    background: #f1fff7;
}

.galaxy-map-legend .legend-ordinary-subsector {
    color: #9fd5e8;
    background: #9fd5e8;
}

.galaxy-map-legend .legend-building-subsector {
    color: #ffc66d;
    background: #ffc66d;
}

@media (max-width: 560px) {
    .galaxy-map-legend {
        gap: 6px 10px;
        font-size: 10px;
    }
}
