/* Подключение шрифта Montserrat из локальной папки fonts */
@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/Montserrat-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/Montserrat-Bold.woff2') format('woff2'),
         url('../fonts/Montserrat-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(to bottom right, #eaf2f8, #d6eaf8);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    color: #333;
    overflow: hidden; /* Предотвращает прокрутку всей страницы */
    
    /* *** ИСПРАВЛЕНИЕ: Усиленная защита от выделения и контекстных меню *** */
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none;   /* Safari */
    -khtml-user-select: none;    /* Konqueror HTML */
    -moz-user-select: none;      /* Old versions of Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
    cursor: default;
}

#game-container {
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 0 20px rgba(174, 214, 241, 0.6);
    display: flex;
    flex-direction: column;
    max-height: 98vh;
    padding: 2vh 2vw;
    text-align: center;
    transition: box-shadow 0.4s ease-out;
    width: auto;
    max-width: 95vw;
    box-sizing: border-box;
    position: relative;
    border: 1px solid rgba(174, 214, 241, 0.3);
}

#game-container:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18), 0 0 25px rgba(174, 214, 241, 0.7);
}

h1 {
    color: #34495e;
    margin-top: 0;
    margin-bottom: 1.5vh;
    font-size: clamp(1.5rem, 4vh, 2.5em);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    letter-spacing: 2px;
    /* text-transform: uppercase;  <-- ЭТА СТРОКА УДАЛЕНА */
    font-weight: 700;
    flex-shrink: 0;
}

#game-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2vh;
    font-size: clamp(0.8rem, 2vh, 1.2em);
    color: #555;
    flex-shrink: 0;
    gap: 0.5vh 10px;
}

#game-info p {
    margin: 0;
    text-shadow: none;
}

#score, #player-name, #levelDisplay, #nextLevelInfo {
    font-weight: bold;
    color: #5699c3;
    text-shadow: none;
}

#gameCanvas {
    background-color: #ffffff;
    border: 3px solid #d5e1e9;
    border-radius: 8px;
    display: block;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.05), 0 5px 15px rgba(0,0,0,0.1);
    margin: 0 auto;
    cursor: default;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1;
    flex-grow: 1;
    flex-shrink: 1;
    min-height: 0;
    /* *** ИСПРАВЛЕНИЕ: Усиленная защита от выделения и контекстных меню на самом канвасе *** */
    outline: none; /* Убирает синюю рамку при фокусе/клике */
    -webkit-tap-highlight-color: transparent; /* Убирает подсветку при тапе на мобильных */
    -webkit-touch-callout: none; /* Дублируем для надежности */
    user-select: none; /* Дублируем для надежности */
}

#ui-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    flex-shrink: 0;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 0 10px;
    margin-top: 2vh;
}

#ui-controls button {
    background-color: #3498db;
    color: white;
    padding: 12px 4px;
    font-size: clamp(0.9rem, 2.2vh, 1.1em);
    cursor: pointer;
    border: none;
    border-radius: 8px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    outline: none;
    min-width: 120px;
    flex-grow: 1;
    max-width: 700px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-shadow: none;
}

#ui-controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    transition: all 0.4s ease;
    transform: skewX(-20deg);
}

#ui-controls button:hover::before {
    left: 100%;
}

#ui-controls button:hover {
    background-color: #2980b9;
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

#ui-controls button:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#rewarded-ad-btn { background-color: #2ecc71; }
#rewarded-ad-btn:hover { background-color: #27ae60; }
#newGameBtn { background-color: #e74c3c; }
#newGameBtn:hover { background-color: #c0392b; }

.modal {
    display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.6); justify-content: center; align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background-color: rgba(255, 255, 255, 0.98); backdrop-filter: blur(8px); margin: auto; padding: 35px; border-radius: 15px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); text-align: center; max-width: 450px; width: 90%; color: #333; animation: fadeIn 0.4s ease-out; border: 1px solid rgba(52, 152, 219, 0.3);
}
.modal-content p { font-size: 1.3em; margin-bottom: 30px; line-height: 1.6; text-shadow: none; }
.modal-buttons { display: flex; justify-content: center; gap: 20px; }
.modal-buttons button {
    background-color: #3498db; color: white; padding: 14px 30px; font-size: 1.1em; cursor: pointer; border: none; border-radius: 8px; box-shadow: 0 5px 12px rgba(0,0,0,0.15); transition: all 0.2s ease; outline: none; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px;
}
.modal-buttons button:hover { transform: translateY(-2px); box-shadow: 0 7px 18px rgba(0,0,0,0.25); }
#newGameConfirmYes { background-color: #28a745; }
#newGameConfirmYes:hover { background-color: #218838; }
#newGameConfirmNo { background-color: #dc3545; }
#newGameConfirmNo:hover { background-color: #c82333; }

/* --- ИЗМЕНЕНО: Добавлены новые стили для окна перехода на новый уровень --- */
#levelCompleteModal .modal-content p {
    font-size: 1.6em;
    font-weight: bold;
    color: #2980b9; /* Насыщенный синий цвет */
    line-height: 1.5;
}

#levelCompleteModal #continueToNextLevelBtn {
    background-color: #2ecc71; /* Зеленый цвет, как у кнопки с наградой */
}

#levelCompleteModal #continueToNextLevelBtn:hover {
    background-color: #27ae60; /* Затемненный зеленый при наведении */
}


.next-ball-preview {
    display: inline-block; width: 20px; height: 20px; border-radius: 50%; margin: 0 5px; border: 2px solid rgba(170, 220, 240, 0.5); vertical-align: middle; box-shadow: inset 0 0 5px rgba(170, 220, 240, 0.6), 0 0 8px rgba(170, 220, 240, 0.7); background-color: transparent;
}
.next-ball-preview img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }

@media (max-height: 600px) and (orientation: landscape) {
    #game-container {
        display: grid;
        grid-template-columns: minmax(180px, 35%) 1fr;
        grid-template-rows: auto auto 1fr; 
        gap: 1vh 2vw;
        align-items: center;
        padding: 2vh 2vw;
    }
    h1 { grid-column: 1; grid-row: 1; margin-bottom: 0; font-size: clamp(1.1rem, 4vh, 1.5rem); }
    #game-info { grid-column: 1; grid-row: 2; flex-direction: column; align-items: flex-start; text-align: left; margin-bottom: 0; gap: 0.8vh; font-size: clamp(0.7rem, 2vh, 0.9rem); }
    #gameCanvas { grid-column: 2; grid-row: 1 / span 3; max-width: 100%; max-height: 100%; width: auto; height: auto; align-self: center; justify-self: center; margin: 0; }
    #ui-controls { grid-column: 1; grid-row: 3; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 1.5vh; width: 100%; max-width: none; margin: 0; padding: 0; }
    #ui-controls button { flex-grow: 0; }
}

@media (max-width: 768px) and (orientation: portrait) {
    #game-container { padding: 1.5vh 2vw; }
    h1 { font-size: clamp(1.2rem, 3.5vh, 1.6rem); margin-bottom: 1vh; letter-spacing: 1px; }
    #game-info { font-size: clamp(0.7rem, 1.8vh, 0.9rem); margin-bottom: 1.5vh; gap: 0.5vh 8px; }
    #ui-controls { gap: 10px; margin-top: 1.5vh; }
    #ui-controls button { padding: 10px 4px; font-size: clamp(0.8rem, 2vh, 1rem); }
    .next-ball-preview { width: 15px; height: 15px; }
}

@media (max-width: 400px) and (orientation: portrait) {
    #ui-controls { flex-direction: column; align-items: center; gap: 10px; }
    #ui-controls button { width: 90%; max-width: 280px; }
}

/* --- ИЗМЕНЕНО: Ненужные стили для #adInterstitialModal удалены --- */

#gameCompletedScreen .modal-content { background: linear-gradient(135deg, #a8e063, #56ab2f); backdrop-filter: blur(8px); margin: auto; padding: 40px; border-radius: 20px; box-shadow: 0 15px 30px rgba(0, 255, 0, 0.4), 0 0 40px rgba(0, 255, 0, 0.3); text-align: center; max-width: 500px; width: 90%; color: #fff; animation: fadeInScaleUp 0.6s ease-out forwards; border: 2px solid rgba(255, 255, 255, 0.5); }
#gameCompletedScreen .modal-content p { font-size: 2em; margin-bottom: 25px; line-height: 1.5; font-weight: bold; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); }
#gameCompletedScreen .modal-buttons button { background-color: #ffffff; color: #56ab2f; padding: 16px 35px; font-size: 1.2em; border-radius: 10px; box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2); transition: all 0.3s ease; text-transform: uppercase; font-weight: bold; letter-spacing: 1px; }
#gameCompletedScreen .modal-buttons button:hover { background-color: #f0f0f0; color: #3d7a21; transform: translateY(-4px) scale(1.02); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3); }
@keyframes fadeInScaleUp { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

/* --- НОВЫЕ СТИЛИ ДЛЯ УВЕДОМЛЕНИЙ В СТИЛЕ ИГРЫ --- */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.game-notification {
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-weight: bold;
    font-size: clamp(0.9rem, 2vh, 1.1em);
    padding: 12px 22px;
    border-radius: 8px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.25);
    min-width: 280px;
    max-width: 90vw;
    text-align: center;
    pointer-events: all;
    animation: slideInUpFade 0.4s ease-out forwards;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.5s ease-in, transform 0.5s ease-in;
}
.game-notification.fade-out {
    opacity: 0;
    transform: scale(0.8);
}
.game-notification.info {
    background-color: rgba(52, 73, 94, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.game-notification.success {
    background-color: rgba(39, 174, 96, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.game-notification.error {
    background-color: rgba(192, 57, 43, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
@keyframes slideInUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}