@import url('https://fonts.googleapis.com/css2?family=Play:wght@400;700&display=swap');

:root {
    --main-blue: #00a8ff;
    --bright-yellow: #fbc531;
    --soft-coral: #ff7f50;
    --pure-white: #ffffff;
    --grass-green: #4cd137;
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
}

body, html {
    margin: 0; padding: 0;
    min-height: 100%;
    font-family: 'Play', sans-serif;
    overflow: hidden;
}

.game-world {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.1)),
                url('../img/Main_background.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px;
}

/* Кнопка языка */
.top-interface { 
    position: absolute; 
    top: 20px; 
    left: 20px; 
    z-index: 100; 
}

.nav-cluster {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

/* «Назад» / «На главную» — как на странице локаций */
button.back-btn {
    background: var(--main-blue);
    border: 3px solid white;
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 0px #0097e6;
    transition: transform 0.1s;
}

button.back-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.lang-switcher {
    background: var(--soft-coral);
    border: 3px solid white;
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0px #d35400;
    transition: transform 0.1s;
}

.lang-switcher:active { transform: translateY(2px); box-shadow: 0 2px 0px #d35400; }

/* Название */
.header-banner {
    margin-top: 50px;
    background: var(--pure-white);
    border: 6px solid var(--main-blue);
    padding: 10px 40px;
    border-radius: 50px;
    z-index: 10;
}

#game-title,
.header-banner h1 {
    margin: 0;
    font-size: 2.5rem;
    color: var(--main-blue);
    text-align: center;
}

/* КНОПКИ МЕНЮ */
.main-menu { 
    margin-top: 40px; 
    display: flex; 
    gap: 30px; 
    z-index: 50; 
}

.magic-card {
    background: white; border: none; border-radius: 40px;
    padding: 8px; cursor: pointer; box-shadow: 0 10px 0px rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

.magic-card:active { transform: translateY(4px); box-shadow: 0 6px 0px rgba(0,0,0,0.1); }

.card-inner {
    padding: 30px 60px;
    border-radius: 35px;
    display: flex; flex-direction: column; align-items: center;
    gap: 10px;
}

.card-inner span:last-child { font-size: 1.8rem; font-weight: bold; }
.loc .card-inner { background: var(--grass-green); border: 4px solid #44bd32; color: white; }
.arc .card-inner { background: var(--bright-yellow); border: 4px solid #e1b12c; color: #2f3640; }
.icon { font-size: clamp(2.25rem, 12vw, 4rem); }

/* --- ПУТЕВОДИТЕЛЬ (ГИД СПРАВА, ТЕКСТ СЛЕВА) --- */

.guide-anchor {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: row; 
    align-items: flex-end;  
    z-index: 40;
    pointer-events: none;
    gap: 15px; 
}

.character-container {
    width: 180px;
    border-radius: 40px;
    border: 5px solid white;
    overflow: hidden;
    background: white;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.2));
    animation: float 4s infinite ease-in-out;
    pointer-events: auto;
    flex-shrink: 0;
}

.main-guide { width: 100%; display: block; border-radius: inherit; object-fit: cover; }

.speech-cloud {
    background: white;
    border: 5px solid var(--bright-yellow);
    padding: 15px 20px;
    border-radius: 25px; /* Скругление сделано равномерным */
    width: 280px;
    margin-bottom: 60px; 
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    position: relative;
    pointer-events: auto;
}

/* Секции :before и :after (хвостик) удалены */

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* --- АДАПТИВНОСТЬ --- */

@media (max-width: 768px) {
    body,
    html {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .game-world {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: max(88px, calc(env(safe-area-inset-top, 0px) + 72px));
        padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
        overflow-x: hidden;
        overflow-y: visible;
    }

    /*
     * Главная (есть .main-menu): название вплотную к верху (safe area),
     * порядок в потоке — заголовок → гид → кнопки; иконки справа остаются в углу.
     */
    .game-world:has(.main-menu) {
        padding-top: max(
            12px,
            calc(env(safe-area-inset-top, 0px) + 10px)
        );
    }

    .header-banner {
        margin-top: 10px;
        width: min(100%, 95vw);
        max-width: 100%;
        padding: 10px 14px;
    }

    .game-world:has(.main-menu) .header-banner {
        margin-top: 0;
        margin-bottom: 14px;
        align-self: center;
        /* чуть левее центра: лишний зазор справа при выравнивании */
        margin-right: clamp(16px, 5vw, 40px);
        margin-left: 0;
        /* узже полная ширина, чтобы текст не заходил под колонку флага и настроек */
        width: min(100%, calc(100vw - 88px));
        max-width: 480px;
    }

    #game-title,
    .header-banner h1 { font-size: clamp(1.1rem, 4.5vw, 1.5rem); }

    .main-menu {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: stretch;
        width: min(100%, 92vw);
        max-width: 400px;
        margin-top: 32px;
        gap: 10px;
    }

    .game-world:has(.main-menu) .main-menu {
        margin-top: 22px;
    }

    .magic-card {
        width: 100%;
        max-width: 100%;
    }

    .main-menu .magic-card {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        max-width: none;
        border-radius: 28px;
        padding: 5px;
        box-shadow: 0 6px 0px rgba(0, 0, 0, 0.08);
    }

    .main-menu .magic-card:active {
        box-shadow: 0 3px 0px rgba(0, 0, 0, 0.08);
    }

    .card-inner {
        padding: 18px 24px;
        min-height: 44px;
    }

    .main-menu .card-inner {
        padding: 12px 8px;
        border-radius: 24px;
        gap: 6px;
        min-height: 0;
    }

    .main-menu .loc .card-inner {
        border-width: 3px;
    }

    .main-menu .arc .card-inner {
        border-width: 3px;
    }

    .main-menu .card-inner span:last-child {
        font-size: clamp(0.78rem, 3.1vw, 1.05rem);
        text-align: center;
        line-height: 1.15;
    }

    .main-menu .card-inner .icon {
        font-size: clamp(1.35rem, 6.5vw, 2rem);
    }

    .card-inner span:last-child { font-size: clamp(1.05rem, 4vw, 1.3rem); }

    .guide-anchor {
        position: relative;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        justify-content: flex-end;
        align-items: flex-end;
        margin-top: 32px;
        margin-bottom: max(8px, env(safe-area-inset-bottom, 0px));
        padding-right: 0;
        gap: 10px;
        flex-wrap: wrap;
    }

    .game-world:has(.main-menu) .guide-anchor {
        margin-top: 8px;
        margin-bottom: 0;
        align-self: stretch;
        /* облако слева, герой — прижат вправо в строке */
        justify-content: flex-start;
    }

    .game-world:has(.main-menu) .speech-cloud {
        flex-grow: 0;
        max-width: min(100%, calc(100vw - 100px));
    }

    .game-world:has(.main-menu) .guide-anchor .character-container {
        margin-left: auto;
    }

    .character-container {
        width: min(110px, 28vw);
        flex-shrink: 0;
    }

    .speech-cloud {
        width: 100%;
        max-width: min(100%, calc(100vw - 120px));
        flex-grow: 1;
        min-width: 0;
        margin-bottom: 16px;
        font-size: clamp(0.85rem, 3.2vw, 0.95rem);
        line-height: 1.4;
    }
}

@media (max-width: 480px) {
    .game-world {
        padding-top: max(80px, calc(env(safe-area-inset-top, 0px) + 64px));
    }

    .game-world:has(.main-menu) {
        padding-top: max(
            10px,
            calc(env(safe-area-inset-top, 0px) + 8px)
        );
    }

    .header-banner {
        border-width: 4px;
        border-radius: 28px;
        padding: 8px 12px;
    }

    .game-world:has(.main-menu) .header-banner {
        margin-bottom: 12px;
        width: min(100%, calc(100vw - 84px));
        margin-right: clamp(12px, 4.5vw, 32px);
    }

    .game-world:has(.main-menu) .speech-cloud {
        max-width: min(100%, calc(100vw - 96px));
    }

    #guide-text {
        margin: 0;
    }

    .magic-card .card-inner {
        padding: 16px 20px;
    }

    .game-world:has(.main-menu) .main-menu {
        margin-top: 18px;
    }

    .main-menu {
        margin-top: 36px;
        max-width: min(100%, 360px);
        gap: 8px;
    }

    .main-menu .card-inner {
        padding: 10px 6px;
        border-radius: 20px;
    }

    .main-menu .card-inner .icon {
        font-size: clamp(1.2rem, 6vw, 1.75rem);
    }

    .main-menu .card-inner span:last-child {
        font-size: clamp(0.72rem, 2.9vw, 0.98rem);
    }
}
.reset-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #e74c3c; /* Красный цвет для предупреждения */
    color: white;
    border: 3px solid white;
    padding: 10px 20px;
    border-radius: 15px;
    font-family: 'Play', sans-serif;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 0px #c0392b;
}

.reset-btn:hover {
    transform: scale(1.05);
    background: #ff5e4d;
}

.reset-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0px #c0392b;
}

.reset-btn .icon {
    font-size: 1.2rem;
}

.settings-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 20px 32px;
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

.settings-screen .reset-btn {
    position: static;
    margin-top: 8px;
}

.settings-music-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.95);
    border: 5px solid var(--main-blue);
    border-radius: 24px;
    padding: 18px 20px;
    margin-bottom: 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.settings-subheading {
    margin: 0 0 14px;
    font-size: 1.2rem;
    color: var(--main-blue);
    text-align: center;
}

.music-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.music-row:last-of-type {
    margin-bottom: 0;
}

.music-toggle-row label {
    flex: 1;
    font-weight: 700;
    color: #2f3640;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.music-toggle-input {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.music-volume-row {
    align-items: center;
}

.music-volume-row label {
    flex: 0 0 100%;
    font-weight: 700;
    color: #2f3640;
    margin-bottom: 4px;
}

@media (min-width: 400px) {
    .music-volume-row label {
        flex: 0 1 auto;
        margin-bottom: 0;
        min-width: 100px;
    }
}

#music-volume {
    flex: 1;
    min-width: 120px;
    height: 32px;
    cursor: pointer;
}

.music-volume-value {
    min-width: 3rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--main-blue);
}

@media (max-width: 768px) {
    .settings-music-card {
        padding: 14px 16px;
        border-width: 4px;
    }

    .settings-subheading {
        font-size: 1.05rem;
    }
}