/*
========================================================
ВСТАВКА ФОНА ИЗ GITHUB PAGES
Если хотите заменить тёмно-серый фон на картинку из вашего GitHub Pages,
раскомментируйте код ниже и вставьте вашу ссылку!
Например: background-image: url("https://george-stone-pax.github.io/my-game-assets/bg-image.jpg");
========================================================
*/
/*
body {
    background-image: url("ВАША_ССЫЛКА_ИЗ_GITHUB_PAGES");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
*/

/* ================= БАЗОВЫЕ СТИЛИ ================= */
body, html {
    margin: 0;
    padding: 0;
    font: normal 0/0 Arial, Helvetica, sans-serif;
    background: #2c3e50; /* Глубокий современный темный фон */
    overflow: hidden;
    color: #fff;
    
    /* Отключаем случайный pull-to-refresh (свайп вниз) на телефонах */
    overscroll-behavior-y: contain; 
    
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
body, html, .flipper, .f, .b, #g { width: 100%; height: 100%; }

a {
    text-decoration: none; color: #fff; display: block;
    font: bold 18px/75px 'Open Sans', sans-serif;
    text-transform: uppercase; text-align: center; padding: 0; margin: 0 1px;
    transition: all 0.2s ease;
}
a:hover { color: #f1c40f; background: rgba(255, 255, 255, .1); }

/* ================= СТАРТОВЫЙ ЭКРАН И МЕНЮ УРОВНЕЙ ================= */
.logo { width: 450px; height: 450px; position: absolute; top: 50%; left: 50%; margin: -225px 0 0 -225px; transition: transform 0.3s ease;}
.logo .card { width: 50%; height: 50%; cursor: pointer; position: relative; }
.logo .card.left.active { z-index: 2; }
.logo .card.left.active + .card { opacity: 0; }
.logo .card.left.active .b { margin-left: -100%; }
.logo .f { font: normal 130px/225px 'Open Sans', sans-serif; text-align: center; text-transform: uppercase; }
.logo .c2 { transform: scale(-1, 1); -webkit-transform: scale(-1, 1); }

.logo .contentbox { width: 200%; font: normal 12px/16px 'Open Sans', sans-serif; text-align: left; }
.logo .contentbox.levels { width: 100%; }
.logo .contentbox .padded { padding: 0 15px; }
.logo .contentbox h2 { font-size: 24px; padding: 0; margin: 28px 0; text-transform: uppercase; }
.logo .contentbox p { line-height: 14px; margin: 14px 0; }

#stats h2 i { margin-right: 10px; vertical-align: top; font: italic normal 9px/8px 'Open Sans', sans-serif; color: rgba(255,255,255, .4); }
#stats ul { width: 50%; display: inline-block; margin: 0; padding: 0; list-style-type: none; vertical-align: top; line-height: 22px; }
#stats li { display: block; margin: 0; padding: 0; }
#stats li b { display: inline-block; font-size: 12px; width: 95px; }
#stats a { position: absolute; bottom: 0; width: 100%; margin-left: -15px; }

.logo .info { font-size: 11px; line-height: 16px; text-align: center; color: rgba(255,255,255, .5); padding: 0 25px; }

/* === СЕТКА КЛАССОВ (3х3) === */
.levels .grades-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    height: 100%; width: 100%;
    gap: 2px; /* Аккуратные отступы между кнопками уровней */
}
.levels .grades-grid a {
    line-height: normal; display: flex; flex-direction: column;
    align-items: center; justify-content: center; font-size: 14px;
    margin: 0; border: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}
.levels .grades-grid a:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.02);
}

/* === ПОЛЕ ДЛЯ СВОИХ СЛОВ === */
.custom-words textarea {
    width: 90%;
    border-radius: 5px;
    padding: 8px;
    margin-top: 5px;
    font-size: 14px;
    color: #333;
    background: #fff;
    resize: none;
    border: none;
    font-family: 'Open Sans', sans-serif;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.custom-words .play-custom {
    background: #16A085;
    border-radius: 5px;
    line-height: 40px;
    margin-top: 10px;
    transition: all 0.3s;
}
.custom-words .play-custom:hover {
    background: #12806a;
    transform: translateY(-2px);
}

/* ================= ЭКРАН ИГРЫ (КАРТОЧКИ) ================= */
#g { margin-top: 4px; transition: transform 0.3s ease; }
#g .found { display: inline-block; pointer-events: none; }

.card { display: inline-block; -webkit-perspective: 1000; -moz-perspective: 1000; cursor: pointer; }
.card:not(.active):hover .f { opacity: .9; box-shadow: inset 0 0 0 1px #fff; }

/* Текстовые карточки */
.text-card {
    font-family: 'Open Sans', sans-serif;
    font-weight: bold;
    color: #fff;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4); 
}

/* Анимация переворота */
.flipper { position: relative; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; width: 100%; height: 100%; }
.f, .b { position: absolute; top: 0; left: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2); -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; }
.f { background: #16A085; z-index: 1; }
.b { background: #C0392B; opacity: 0; }
.card.active .b { z-index: 2; opacity: 1; }

.card, .flipper, .logo .b { transition: 400ms cubic-bezier(0.4, 0.2, 0.2, 1); }
.card.active .flipper, .b { transform: rotateY(180deg); -webkit-transform: rotateY(180deg); }
.logo .f, .pause::before { -webkit-text-stroke: 1px #fff; }

/* КРУТАЯ ШТУКА: Анимация при нахождении правильной пары */
@keyframes successPulse {
    0% { transform: rotateY(180deg) scale(1); box-shadow: 0 0 0px rgba(46, 204, 113, 0); }
    50% { transform: rotateY(180deg) scale(1.05); box-shadow: 0 0 15px 5px rgba(46, 204, 113, 0.6); z-index: 10;}
    100% { transform: rotateY(180deg) scale(1); box-shadow: 0 0 0px rgba(46, 204, 113, 0); }
}
.card.found .flipper { animation: successPulse 0.5s ease-out; }
.card.found .b { background: #27ae60; transition: background 0.3s; } /* Становится зеленой */

/* Пауза */
.pause { position: absolute; width: 100%; height: 100%; left: 0; top: 0; z-index: 100; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(3px); }
.pause::before {
    content: 'ПАУЗА'; width: 100%; position: absolute; margin-top: -100px; top: 50%;
    background: transparent; color: #fff; font: bold 60px/200px 'Open Sans', sans-serif; display: block; text-align: center;
}

/* ================= ЭЛЕМЕНТЫ УПРАВЛЕНИЯ (ЗВУК И ПОЛНОЭКРАННЫЙ РЕЖИМ) ================= */
.game-controls {
    position: fixed; top: 20px; right: 20px; z-index: 1000;
    display: flex; align-items: center; gap: 15px;
    background: rgba(0, 0, 0, 0.4); padding: 10px 15px; border-radius: 12px;
    backdrop-filter: blur(5px); border: 1px solid rgba(255,255,255,0.1);
}
#fullscreen-btn {
    background: none; border: none; color: white; font-size: 24px;
    cursor: pointer; transition: transform 0.2s, color 0.2s; padding: 0;
}
#fullscreen-btn:hover { transform: scale(1.2); color: #f1c40f; }
.volume-control { display: flex; align-items: center; gap: 8px; color: white; font-size: 18px; }
input[type=range] { cursor: pointer; accent-color: #16A085; }

/* ================= ОКНО ПОХВАЛЫ (ФИНАЛ) ================= */
.hidden { display: none !important; }

#evaluation-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); z-index: 9999;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #fff; color: #333;
    padding: 40px; border-radius: 12px; text-align: center;
    max-width: 400px; width: 85%;
    font: normal 18px/1.5 'Open Sans', sans-serif;
    box-shadow: 0px 15px 40px rgba(0,0,0,0.6);
    transform: translateY(0); animation: slideUp 0.4s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.modal-content h2 { margin-top: 0; color: #27ae60; font-size: 28px; font-weight: bold; }
.modal-content p { font-size: 18px; margin: 15px 0 25px; color: #555; }

.modal-content button {
    background: #16A085; color: #fff; border: none; padding: 14px 25px;
    font-size: 18px; font-weight: bold; border-radius: 8px; cursor: pointer;
    transition: all 0.3s; width: 100%; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.modal-content button:hover { background: #12806a; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.2); }

/* ================= АДАПТИВ ДЛЯ МОБИЛЬНЫХ ================= */
@media all and (max-width: 640px) and (min-width: 0px) {
    a { line-height: 50px; font-size: 13px; }
    .logo { width: 300px; height: 300px; margin: -150px 0 0 -150px; }
    .logo .f { font: normal 80px/150px 'Open Sans', sans-serif; }
    .logo .contentbox h2 { font-size: 16px; margin: 24px 0; }
    .logo .instructions h2 { display: none; }
    .logo .instructions.contentbox p:nth-child(3) { display: none; }
    #stats li b { width: auto; }
    
    .game-controls { top: 10px; right: 10px; padding: 6px 12px; gap: 10px;}
    #fullscreen-btn { font-size: 20px; }
    .modal-content { font-size: 16px; padding: 25px; }
    
    /* 
    === СУПЕР-СЕТКА ДЛЯ ТЕЛЕФОНОВ ===
    Переопределяем инлайн-стили JS (размер карточек) через !important.
    Создаем жесткую CSS Grid сетку: ровно 3 колонки, и 6 строк (для 18 карточек).
    */
    #g {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(6, 1fr) !important;
        gap: 4px; /* Отступы между карточками */
        padding: 4px; 
        box-sizing: border-box;
    }
    
    #g .card {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Делаем шрифт на карточках крупнее для мобильных экранов */
    #g .card .b {
        font-size: 4.5vw !important; 
    }
                             }
