:root {
    --primary-color: #3498db;
    --secondary-color: #e74c3c;
    --background-color: #2c3e50;
    --text-color: #ecf0f1;
    --button-color: #2980b9;
    --button-hover: #1abc9c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 800px;
    height: 600px;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 4/3;
}

#game-content {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #1a1a2e;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Стили для меню */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(26, 26, 46, 0.9);
    border-radius: 8px;
    z-index: 10;
}

.hidden {
    display: none;
}

h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 80%;
    max-width: 300px;
}

button {
    padding: 12px 24px;
    font-size: 1.2rem;
    background-color: var(--button-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
}

/* Стили для HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    display: flex;
    gap: 20px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 4px;
}

/* Стили для элементов управления на тачскрине */
#touch-controls {
    position: absolute;
    display: none;
    z-index: 5;
}

/* Портретная ориентация */
@media (orientation: portrait) {
    #game-container {
        width: 90vmin;
        height: calc(90vmin * 3/4);
    }
    
    #touch-controls.portrait {
        display: flex;
        flex-direction: column;
        bottom: 20px;
        left: 0;
        right: 0;
        justify-content: space-between;
        padding: 0 5%;
    }
    
    .portrait .d-pad {
        order: 2;
        margin: 20px auto 0 auto;
    }
    
    .portrait .action-buttons {
        order: 1;
        margin: 0 auto;
    }
}

/* Альбомная ориентация */
@media (orientation: landscape) {
    #game-container {
        width: calc(100vh * 4/3);
        height: 100vh;
    }
    
    #touch-controls.landscape {
        display: flex;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        justify-content: space-between;
        align-items: center;
        pointer-events: none;
    }
    
    .landscape .d-pad {
        margin-left: 5%;
        pointer-events: auto;
    }
    
    .landscape .action-buttons {
        margin-right: 5%;
        pointer-events: auto;
    }
}

.d-pad {
    width: 150px;
    height: 150px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
}

.d-pad-button {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none;
}

.d-pad-button:active {
    background-color: rgba(255, 255, 255, 0.5);
}

.d-pad-up {
    grid-column: 2;
    grid-row: 1;
}

.d-pad-left {
    grid-column: 1;
    grid-row: 2;
}

.d-pad-right {
    grid-column: 3;
    grid-row: 2;
}

.d-pad-down {
    grid-column: 2;
    grid-row: 3;
}

.action-buttons {
    display: flex;
    gap: 20px;
}

.action-button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: rgba(231, 76, 60, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    user-select: none;
    touch-action: none;
}

.action-button:active {
    background-color: rgba(231, 76, 60, 0.5);
}

/* Настройки */
.settings-group {
    margin-bottom: 1.5rem;
    width: 80%;
    max-width: 400px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Таблица рекордов */
#highscores-list {
    width: 80%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    margin-bottom: 5px;
    border-radius: 4px;
}

.highscore-rank {
    font-weight: bold;
    color: var(--primary-color);
}

/* Адаптивность для очень маленьких экранов */
@media (max-height: 600px) and (orientation: portrait) {
    #game-container {
        width: 80vmin;
        height: calc(80vmin * 3/4);
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    button {
        padding: 8px 16px;
        font-size: 1rem;
    }
    
    .d-pad {
        width: 120px;
        height: 120px;
    }
    
    .action-button {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
}