/* Общие цвета и шрифты интерфейса. */
:root {
    color-scheme: dark;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --text: #f4efe5;
    --muted: #9ca3ae;
    --gold: #eebd68;
    --line: #ffffff12;
}

/* Базовые правила страницы. */
* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #0b1018;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    background:
        radial-gradient(
            circle at 14% 18%,
            #31445a55,
            transparent 30%
        ),
        radial-gradient(
            circle at 86% 12%,
            #7a58332e,
            transparent 27%
        ),
        radial-gradient(
            circle at 50% 100%,
            #26384d38,
            transparent 42%
        ),
        linear-gradient(
            135deg,
            #070a0f,
            #0d131c 48%,
            #080b11
        );
    background-attachment: fixed;
}

/* Едва заметный узор заполняет пустое место вокруг игры на широком экране. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            120deg,
            transparent 0 46px,
            #ffffff05 47px 48px
        );
    mask-image: linear-gradient(
        90deg,
        #000000,
        transparent 34%,
        transparent 66%,
        #000000
    );
}

button {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

button:focus {
    outline: none;
}

button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Крупная картинка локации использует тот же PNG, что и кнопка входа. */
.location-scene-image {
    display: block;
    width: 76px;
    height: 76px;
    object-fit: contain;
    filter: drop-shadow(0 7px 10px #0008);
    user-select: none;
    pointer-events: none;
}

/* Главный контейнер игры. */
.game-shell {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    margin: auto;
    padding: 18px 0 28px;
    filter: drop-shadow(0 24px 60px #00000073);
}

/* Компактный возврат не занимает место среди основных карточек экрана. */
.screen-corner-button {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    padding: 7px 10px;
    border: 1px solid #d3aa5966;
    border-radius: 8px;
    color: #ead7b1;
    background: #0d121acc;
    box-shadow: 0 5px 18px #0000004d;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.screen-corner-button:hover {
    border-color: #e0b96f;
    background: #171d27e8;
}

.screen-corner-button[hidden] {
    display: none;
}

/* Общий плавный переход между самостоятельными окнами игры. */
#locationScreen,
#battleScreen,
#fortsScreen {
    transition: opacity 0.15s ease;
}

.screen-leaving {
    pointer-events: none;
    opacity: 0;
}

.screen-entering {
    pointer-events: none;
    animation: screen-enter 0.1s ease both;
}

@keyframes screen-enter {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Уважает системную настройку уменьшения движения. */
@media (prefers-reduced-motion: reduce) {
    #locationScreen,
    #battleScreen,
    #fortsScreen {
        transition: none;
    }

    .screen-entering {
        animation: none;
    }
}

/* Карточка монстра, загруженного из игрового API. */
.monster-api-card {
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.monster-api-card strong {
    margin-bottom: 10px;
    font-size: 16px;
}

.monster-api-card small {
    margin-top: 6px;
}

.monster-api-card:hover {
    transform: translateY(-2px);
}

.loading-card {
    grid-column: 1 / -1;
}

.api-error-card {
    grid-column: span 3;
    border-color: #b64b3f88;
}

/* Нижнее меню служит постоянным выходом из самостоятельных экранов. */
.bottom-nav {
    --bottom-nav-transition: 0.24s cubic-bezier(0.22, 0.75, 0.24, 1);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 5px;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 15px 15px;
    background: #111720f5;
    transition: transform var(--bottom-nav-transition);
}

.bottom-nav > button:not(.bottom-nav-toggle) {
    display: grid;
    grid-template-rows: 58px 14px;
    align-items: center;
    justify-items: center;
    gap: 3px;
    min-width: 0;
    padding: 3px 1px 5px;
    border: 0;
    color: #7f8995;
    background: transparent;
    font-size: 17px;
    cursor: pointer;
}

.bottom-nav > button:not(.bottom-nav-toggle) span {
    width: 100%;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    white-space: nowrap;
}

.bottom-nav .active {
    color: var(--gold);
}

.bottom-nav-toggle {
    position: absolute;
    top: -25px;
    left: 50%;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 52px;
    height: 25px;
    padding: 0 0 4px;
    border: 1px solid #d3aa594f;
    border-bottom: 0;
    border-radius: 11px 11px 0 0;
    color: #dfbd78;
    background: #111720f5;
    box-shadow: 0 -5px 15px #0005;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transform: translateX(-50%);
    backdrop-filter: blur(12px);
}

.bottom-nav.is-collapsed {
    transform: translate(-50%, 100%);
}

.bottom-nav.is-collapsed .bottom-nav-toggle {
    padding: 4px 0 0;
    border-top-color: #d3aa5980;
}

/* Небольшая общая подпись внизу игровых экранов. */
.game-footer {
    padding: 11px 8px;
    color: #646b75;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-align: center;
}

/* Всплывающее уведомление для неподключённых экранов. */
.toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    z-index: 9;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 10px 15px;
    border: 1px solid #ffffff16;
    border-radius: 9px;
    background: #202a36f5;
    box-shadow: 0 10px 35px #0009;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
    white-space: pre-line;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 10px);
    transition: 0.2s;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Адаптация интерфейса под телефон. */
/* Временно используем мобильную компоновку на экранах любой ширины. */
@media (max-width: 9999px) {
    body::before {
        display: block;
        opacity: 0.45;
        mask-image: none;
    }

    body {
        background-attachment: scroll;
    }

    .game-shell {
        width: min(520px, 100%);
        padding: 0 0 92px;
        background: #111720;
        filter: none;
    }

    .bottom-nav {
        position: fixed;
        left: 50%;
        right: auto;
        bottom: 0;
        width: min(520px, 100%);
        z-index: 6;
        padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
        border-top: 1px solid #ffffff10;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 0;
        background: #111720f5;
        backdrop-filter: blur(12px);
        transform: translateX(-50%);
    }

    .bottom-nav.is-collapsed {
        transform: translate(-50%, 100%);
    }

    .game-shell.bottom-nav-collapsed {
        padding-bottom: 18px;
    }
}

/* Стиль нижнего меню */
.bottom-nav-image {
    width: 58px;
    height: 58px;
    object-fit: contain;
    display: block;
    margin: auto;
    transform: none;
}

.bottom-nav-world,
.bottom-nav-hero,
.bottom-nav-forge,
.bottom-nav-bag,
.bottom-nav-equip {
    width: 58px;
    height: 58px;
}
