* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Стили для фона Пенроуза */
#penrose-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    color: white;
    overflow: hidden;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    background: #000;
    display: block;
}

#touch-controls {
    position: absolute;
    display: none;
    z-index: 10;
}

#touch-controls.portrait {
    flex-direction: column;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 20px;
    justify-content: space-between;
    align-items: center;
}

#touch-controls.landscape {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    justify-content: space-between;
}

.control-group {
    display: flex;
    gap: 20px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
}

.d-pad-button {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    user-select: none;
}

.touch-button {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    user-select: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(135deg, 
        rgba(44, 62, 80, 0.95), 
        rgba(52, 73, 94, 0.98)
    );
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 20px;
    border: 2px solid rgba(78, 205, 196, 0.5);
    box-shadow: 
        0 0 30px rgba(78, 205, 196, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    min-width: 350px;
    max-width: 90%;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        rgba(78, 205, 196, 0.1) 0%,
        transparent 70%
    );
    animation: rotateGradient 20s linear infinite;
    pointer-events: none;
}

.menu-content {
    min-width: 400px;
}

.dialog-content {
    min-width: 350px;
}

.modal-content h1 {
    font-size: 3.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: #4ecdc4;
    position: relative;
}

.modal-content h1::after,
.modal-content h2::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: transparent;
    text-shadow: 
        0 0 10px rgba(255, 107, 107, 0.5),
        0 0 20px rgba(255, 107, 107, 0.3),
        0 0 30px rgba(255, 107, 107, 0.2);
    z-index: -1;
}

.score-display {
    margin: 1.5rem 0;
    font-size: 1.3rem;
    color: #fff;
}

.score-display span {
    font-weight: bold;
    color: #ff6b6b;
    font-size: 1.5rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.dialog-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    margin-top: 1.5rem;
}

.menu-buttons button,
.dialog-buttons button {
    padding: 1.2rem 2rem;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #4ecdc4, #45b7aa);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    width: 100%;
    transform: translateZ(0);
}

.menu-buttons button:hover,
.dialog-buttons button:hover {
    transform: translateY(-3px) translateZ(10px);
    box-shadow: 
        0 10px 25px rgba(78, 205, 196, 0.4),
        0 5px 15px rgba(255, 107, 107, 0.3);
    background: linear-gradient(135deg, #45b7aa, #3aa99c);
}

.primary-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff5252) !important;
}

.primary-btn:hover {
    background: linear-gradient(135deg, #ff5252, #ff3838) !important;
    box-shadow: 
        0 10px 25px rgba(255, 107, 107, 0.4),
        0 5px 15px rgba(255, 107, 107, 0.3) !important;
}

.settings-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.settings-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #fff;
    font-weight: 500;
}

.settings-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #34495e;
    outline: none;
    -webkit-appearance: none;
}

.settings-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4ecdc4;
    cursor: pointer;
    border: 2px solid #fff;
}

.settings-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: #4ecdc4;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes menuAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes rotateGradient {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.modal-content {
    animation: fadeIn 0.8s ease-out;
}

/* Адаптивность */
@media (max-width: 768px) {
    .modal-content {
        padding: 2rem;
        margin: 1rem;
    }
    
    .modal-content h1 {
        font-size: 2.5rem;
    }
    
    .modal-content h2 {
        font-size: 2rem;
    }
    
    .menu-buttons button,
    .dialog-buttons button {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
    }
    
    .d-pad-button {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .touch-button {
        width: 60px;
        height: 60px;
        font-size: 1rem;
    }
}