.app-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.app-modal.show {
    opacity: 1;
    visibility: visible;
}

.app-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.app-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    padding: 0;
}

.app-modal.show .app-modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.app-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    z-index: 10;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-modal-close:hover {
    background-color: #f5f5f5;
    color: #333;
}

.app-modal-header {
    text-align: center;
    padding: 32px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.app-modal-header h3 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.app-modal-header p {
    margin: 0;
    color: #666;
    font-size: 16px;
    line-height: 1.4;
}

.app-modal-body {
    padding: 24px;
}

.device-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.device-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.device-btn:hover {
    border-color: #0C5456;
    background-color: #f8fffe;
}

.device-btn.selected {
    border-color: #0C5456;
    background-color: #f0fffe;
    box-shadow: 0 4px 12px rgba(12, 84, 86, 0.1);
}

.device-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: #f8f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0C5456;
}

.device-btn.selected .device-icon {
    background: #0C5456;
    color: white;
}

.device-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    line-height: 1.2;
}

.device-store {
    font-size: 14px;
    color: #666;
    line-height: 1.2;
}

.app-modal-actions {
    text-align: center;
}

.app-modal-actions .btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.app-modal-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.app-modal-fallback {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.app-modal-fallback a {
    color: #0C5456;
    text-decoration: none;
    font-weight: 500;
}

.app-modal-fallback a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .app-modal-content {
        width: 95%;
        margin: 20px;
        border-radius: 12px;
    }
    
    .app-modal-header {
        padding: 24px 20px 16px;
    }
    
    .app-modal-header h3 {
        font-size: 20px;
    }
    
    .app-modal-header p {
        font-size: 14px;
    }
    
    .app-modal-body {
        padding: 20px;
    }
    
    .device-btn {
        padding: 14px 16px;
        gap: 12px;
    }
    
    .device-icon {
        width: 40px;
        height: 40px;
    }
    
    .device-name {
        font-size: 15px;
    }
    
    .device-store {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .app-modal-content {
        width: 98%;
        margin: 10px;
        max-height: 95vh;
    }
    
    .device-selection {
        gap: 8px;
    }
    
    .device-btn {
        padding: 12px 14px;
        gap: 10px;
    }
    
    .device-icon {
        width: 36px;
        height: 36px;
    }
    
    .device-name {
        font-size: 14px;
    }
    
    .device-store {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-modal,
    .app-modal-content,
    .device-btn,
    .app-modal-close,
    .app-modal-actions .btn {
        transition: none;
    }
}

.app-modal[aria-hidden="true"] {
    display: none;
}