/**
 * Chameleon Snake Game - Responsive Styles
 * 
 * Created: 2025-2026
 * Author: Yaroslav Zotov
 * AI-Assisted: Color scheme and layout suggestions
 * 
 * MIT Licensed
 */

/* Базовые стили для адаптивности */
:root {
    --game-min-width: 320px;
    --game-max-width: 70vh;
    --header-height: 80px;
    --game-padding: 10px;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
    overflow: auto;
    color: white;
    box-sizing: border-box;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: var(--game-max-width);
    min-width: var(--game-min-width);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Адаптивный заголовок игры */
#game-header {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
}

#score-container, #combo-container, 
#best-score-container, #best-combo-container {
    font-size: clamp(16px, 2.5vw, 24px);
    font-weight: bold;
    text-align: center;
    flex: 1;
}

#combo-container {
    text-shadow: none;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* Адаптивный canvas */
#gameCanvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1; /* Квадратный canvas */
    background: rgba(0, 20, 40, 0.85);
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    border: 2px solid #0ff;
    display: block;
    box-sizing: border-box;
}

/* Адаптивный уровень */
#level-container {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    margin: 0 auto;
    padding: 8px 20px;
    text-align: center;
    width: fit-content;
    min-width: 150px;
    border: 2px solid #FFD700;
    box-shadow: 0 4px 8px rgba(255, 215, 0, 0.3);
}

#level-container span {
    font-size: clamp(18px, 2.5vw, 22px);
    font-weight: bold;
}

#current-level {
    font-size: clamp(20px, 3vw, 24px);
}

/* Адаптивный оверлей */
#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    z-index: 10;
    box-sizing: border-box;
    padding: 20px;
}

#start-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Адаптивные экраны меню */
#start-screen, #game-over, #popup {
    text-align: center;
    padding: clamp(15px, 5vw, 30px);
    max-width: 90%;
    width: 100%;
}

/* Адаптивная типографика */
h1 {
    font-size: clamp(24px, 8vw, 48px);
    color: #0ff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.7);
    margin-bottom: 10px;
    word-wrap: break-word;
}

h2 {
    font-size: clamp(20px, 6vw, 36px);
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
    margin: 15px 0;
}

h3 {
    font-size: clamp(18px, 4vw, 28px);
}

p {
    font-size: clamp(14px, 2vw, 20px);
    margin: 10px 0;
    line-height: 1.5;
}

.menu-button {
    display: block;
}

/* Адаптивные кнопки */
button, .menu-button {
    background: linear-gradient(to bottom, #ffcc00, #ff6600);
    border: none;
    border-radius: 50px;
    color: #1a1a2e;
    padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 25px);
    font-size: clamp(14px, 2vw, 22px);
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: 0 5px 15px rgba(255, 102, 0, 0.4);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 90%;
    max-width: 450px;
}

button:hover, .menu-button:hover {
    transform: scale(1.05);
    box-shadow: 0 7px 20px rgba(255, 102, 0, 0.6);
}

/* Адаптивный переключатель языка */
#language-switcher {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    gap: 5px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.language-btn {
    background: none;
    border: none;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: clamp(12px, 2vw, 14px);
    font-weight: bold;
    transition: all 0.3s ease;
    text-transform: uppercase;
    margin-top: 0;
}

.language-btn:hover {
    background: rgba(0, 255, 255, 0.2);
}

.language-btn.active {
    background: #0ff;
    color: #1a1a2e;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
}

/* Адаптивные инструкции и "О проекте" */
#instructions, #about {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    z-index: 10;
    border: 1px solid #0ff;
    padding: clamp(10px, 3vw, 20px);
    overflow-y: auto;
    box-sizing: border-box;
}

#instructions ul {
    text-align: left;
    padding-left: 20px;
    font-size: clamp(12px, 2vw, 18px);
}

#instructions li {
    margin: 8px 0;
}

@keyframes levelUpGlow {
    0% { 
        border-color: #FFD700;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% { 
        border-color: #FFF;
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.9);
    }
    100% { 
        border-color: #FFD700;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
}

.level-up-animation {
    animation: levelUpGlow 1.5s ease-in-out;
}

/* Секции "О проекте" */
.about-content {
    max-width: 800px;
    text-align: left;
    width: 100%;
}

.about-section {
    background: rgba(0, 30, 60, 0.5);
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
    border-left: 4px solid #0ff;
}

.about-section h4 {
    color: #0ff;
    margin-top: 0;
    margin-bottom: 8px;
    font-size: clamp(16px, 3vw, 18px);
}

.about-section p {
    margin: 6px 0;
    font-size: clamp(14px, 2.5vw, 16px);
    line-height: 1.3;
}

/* Медиа-запросы для особых случаев */
@media screen and (max-width: 480px) {
    body {
        padding: 10px;
    }

    button, .menu-button {
        width: 95%;
        padding: 12px 20px;
    }
    
    .header-row {
        flex-direction: column;
        gap: 5px;
    }
    
    #score-container, #combo-container, 
    #best-score-container, #best-combo-container {
        width: 100%;
        text-align: center;
    }
}

@media screen and (max-height: 600px) {
    body {
        padding: 10px;
        align-items: flex-start;
        min-height: auto;
        height: auto;
    }
    
    #game-container {
        gap: 5px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 16px;
    }

    h3 {
        font-size: 14px;
    }

    .about-section h4 {
        margin-bottom: 4px;
        font-size: 14px;
        line-height: 1;
    }

    .about-section p {
        margin: 6px 0;
        font-size: 12px;
        line-height: 1.2;
    }

}

@media screen and (orientation: portrait) and (max-width: 768px) {
    #game-container {
        max-height: 85vh;
        top: -56px;
    }

    #score-container, #combo-container, 
    #best-score-container, #best-combo-container {
        width: 100%;
        text-align: left;
    }

    #level-container {
        position: absolute;
        top: 74px;
        right: 5px;
    }
}

@media screen and (max-height: 768px) {
    #game-container {
        max-width: 65vh;
    }

    h1 {
        font-size: 32px;
    }

    h2 {
        font-size: 24px;
    }

    h3 {
        font-size: 16px;
    }

    .about-section h4 {
        margin-bottom: 4px;
        font-size: 16px;
        line-height: 1;
    }

    .about-section p {
        margin: 6px 0;
        font-size: 14px;
        line-height: 1.2;
    }
}

@media screen and (orientation: landscape) and (max-height: 600px) {
    #game-container {
        max-width: 60vh;
    }
    
    #game-header {
        padding: 5px;
    }
    
    .header-row {
        padding: 3px 5px;
    }
}

.hidden {
    display: none !important;
}

.key {
    display: inline-block;
    background: rgba(0, 255, 255, 0.2);
    border: 1px solid #0ff;
    border-radius: 5px;
    padding: 2px 8px;
    margin: 0 3px;
    font-size: clamp(12px, 2vw, 16px);
}

/* ===== Мобильные кнопки управления ===== */
.mobile-controls {
    display: none; /* скрыты на десктопе по умолчанию */
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    width: 100%;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.control-btn {
    background: linear-gradient(to bottom, #ffcc00, #ff6600);
    border: none;
    border-radius: 50px;
    color: #1a1a2e;
    font-size: 7vw;
    font-weight: bold;
    cursor: pointer;
    width: 21vw;
    height: 14vw;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(255, 102, 0, 0.4);
    transition: all 0.1s ease;
    user-select: none;
    touch-action: manipulation;
    padding: 0;
    line-height: 1;
    margin-top: 10px;
}

.control-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 10px rgba(255, 102, 0, 0.8);
}

.pause-btn {
    font-size: 8vw;
    font-family: "Arial", sans-serif;
}

/* Показываем кнопки только на мобильных устройствах */
@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }
}

/* Для очень маленьких экранов уменьшаем отступы */
@media (max-width: 480px) {
    .controls-row {
        gap: 10px;
    }
}

/* Альбомная ориентация на телефонах */
@media (orientation: landscape) and (max-height: 600px) {
    .mobile-controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .controls-row {
        width: auto;
    }
}
